diff options
Diffstat (limited to 'fixco_custom')
| -rw-r--r-- | fixco_custom/models/account_move.py | 2 | ||||
| -rw-r--r-- | fixco_custom/models/account_move_line.py | 11 | ||||
| -rw-r--r-- | fixco_custom/models/account_payment.py | 6 | ||||
| -rw-r--r-- | fixco_custom/models/stock_inventory.py | 55 | ||||
| -rwxr-xr-x | fixco_custom/models/stock_picking.py | 10 | ||||
| -rw-r--r-- | fixco_custom/views/account_move.xml | 2 | ||||
| -rw-r--r-- | fixco_custom/views/account_move_line.xml | 21 | ||||
| -rw-r--r-- | fixco_custom/views/account_payment.xml | 8 | ||||
| -rw-r--r-- | fixco_custom/views/stock_inventory.xml | 4 |
9 files changed, 81 insertions, 38 deletions
diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py index c1098d0..b1f540e 100644 --- a/fixco_custom/models/account_move.py +++ b/fixco_custom/models/account_move.py @@ -305,6 +305,8 @@ class AccountMove(models.Model): entry.soo_number = ', '.join(soo_list) if entry.move_type == 'out_invoice': + search_inv = entry.search([('move_type', '=', 'out_invoice'), ('id', '=', entry.id), ('invoice_marketplace', '=', entry.sale_id.invoice_mp)], limit=1).invoice_marketplace + entry.invoice_marketplace = search_inv if entry.picking_id: entry.invoice_date = entry.picking_id.date_done diff --git a/fixco_custom/models/account_move_line.py b/fixco_custom/models/account_move_line.py index 1f4ed9d..0c64fe1 100644 --- a/fixco_custom/models/account_move_line.py +++ b/fixco_custom/models/account_move_line.py @@ -6,6 +6,17 @@ class AccountMoveLine(models.Model): qty_outstanding = fields.Float(string='Qty Outstanding', compute='_compute_qty_outstanding') invoice_marketplace = fields.Text("Invoice Mearketplace", compute='_compute_invoice_marketplace') + faktur_pajak = fields.Char(string='Faktur Pajak', compute='_compute_faktur_pajak') + + def _compute_faktur_pajak(self): + for line in self: + line.faktur_pajak = False + move = line.move_id + + if not move: + continue + + line.faktur_pajak = move.efaktur_id.name if move.efaktur_id else False def action_gl_reconcile(self): lines = self diff --git a/fixco_custom/models/account_payment.py b/fixco_custom/models/account_payment.py index 41a2ce5..8f36de6 100644 --- a/fixco_custom/models/account_payment.py +++ b/fixco_custom/models/account_payment.py @@ -5,6 +5,12 @@ from odoo.exceptions import UserError class AccountPayment(models.Model): _inherit = 'account.payment' + def action_multi_reset_to_draft(self): + for payment in self: + if payment.state != 'posted': + raise UserError("Only posted payments can be reset to draft.") + payment.action_draft() + @api.constrains('journal_id') def set_default_journal_id(self): for rec in self: diff --git a/fixco_custom/models/stock_inventory.py b/fixco_custom/models/stock_inventory.py index 1a8f3b0..37104ff 100644 --- a/fixco_custom/models/stock_inventory.py +++ b/fixco_custom/models/stock_inventory.py @@ -20,7 +20,7 @@ class StockInventory(models.Model): ('logistic', 'Logistic'), ('accounting', 'Accounting'), ('approved', 'Approved'), - ], default='logistic', tracking=True) + ], tracking=True) def _generate_number_stock_inventory(self): """Men-generate nomor untuk semua stock inventory yang belum memiliki number.""" @@ -58,45 +58,60 @@ class StockInventory(models.Model): return "00001" # Jika belum ada data, mulai dari 00001 def action_start(self): - if self.approval_state != 'approved' and self.adjusment_type == 'out': - raise UserError('Harus melalui proses approval') - if self.adjusment_type == 'in': - if self.env.user.id not in [10, 14, 20, 21]: - raise UserError("Hanya User tertentu yang dapat melakukan Adjust-In") + if self.env.user.id not in [10, 14, 20, 21, 15]: + raise UserError("Hanya User tertentu yang dapat melakukan Adjust-In/Out") return super(StockInventory, self).action_start() @api.model def create(self, vals): """Pastikan nomor hanya dibuat saat penyimpanan.""" + + if vals.get('adjusment_type') == 'in': + vals['approval_state'] = False + elif vals.get('adjusment_type') == 'out': + vals['approval_state'] = 'logistic' + if 'adjusment_type' in vals and not vals.get('number'): - vals['number'] = False # Jangan buat number otomatis dulu + vals['number'] = False order = super(StockInventory, self).create(vals) if order.adjusment_type: - self._assign_number(order) # Generate number setelah save + self._assign_number(order) return order - - def action_approve(self): + + def action_validate(self): if self.adjusment_type == 'out': - for rec in self: - if rec.approval_state == 'logistic': - if not rec.env.user.id in [10, 14, 20, 21]: - raise UserError("Harus diapprove logistic") - rec.approval_state = 'accounting' - elif rec.approval_state == 'accounting': - if not rec.env.user.id in [13, 24, 2]: - raise UserError("Harus diapprove accounting") - rec.approval_state = 'approved' + + if self.approval_state != 'approved': + + if self.approval_state == 'logistic': + if not self.env.user.id in [10, 14, 20, 21]: + raise UserError("Adjustment Out harus diapprove oleh Logistic") + self.approval_state = 'accounting' + return True + + elif self.approval_state == 'accounting': + if not self.env.user.id in [13, 24, 2]: + raise UserError("Adjustment Out harus diapprove oleh Accounting") + self.approval_state = 'approved' + return super(StockInventory, self).action_validate() + else: - raise UserError("Sudah Approved") + raise UserError("Adjustment Out harus melalui approval terlebih dahulu.") + + return super(StockInventory, self).action_validate() def write(self, vals): """Jika adjusment_type diubah, generate ulang nomor.""" res = super(StockInventory, self).write(vals) if 'adjusment_type' in vals: for record in self: + if record.adjusment_type == 'in': + record.approval_state = False + elif record.adjusment_type == 'out' and record.approval_state == False: + record.approval_state = 'logistic' self._assign_number(record) return res diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py index 0eebe6a..a91274c 100755 --- a/fixco_custom/models/stock_picking.py +++ b/fixco_custom/models/stock_picking.py @@ -126,7 +126,7 @@ class StockPicking(models.Model): ]) if quant: - return quant.quantity + return sum(quant.mapped('quantity')) return 0 @@ -293,10 +293,12 @@ class StockPicking(models.Model): raise UserError( 'Hanya Accounting yang bisa melakukan cancel karena di po nya sudah ada uang muka' ) - res = super(StockPicking, self).action_cancel() - if self.picking_type_code == 'incoming' and self.name.startswith('BU/IN'): - self.set_po_bill_status() + if picking.picking_type_code == 'incoming' and picking.name.startswith('BU/IN'): + picking.set_po_bill_status() + + + res = super(StockPicking, self).action_cancel() return res diff --git a/fixco_custom/views/account_move.xml b/fixco_custom/views/account_move.xml index 3eab56a..ee3cd20 100644 --- a/fixco_custom/views/account_move.xml +++ b/fixco_custom/views/account_move.xml @@ -153,6 +153,7 @@ filter_domain="[ ('invoice_marketplace', 'ilike', self) ]"/> + <field name="soo_number" string="SOO Number" filter_domain="[ @@ -174,6 +175,7 @@ <field name="reklas_used" optional="hide"/> <field name="reklas_used_by" optional="hide"/> <field name="soo_number" optional="hide"/> + <field name="invoice_marketplace" optional="hide"/> </field> </field> </record> diff --git a/fixco_custom/views/account_move_line.xml b/fixco_custom/views/account_move_line.xml index 245bdfe..5b55729 100644 --- a/fixco_custom/views/account_move_line.xml +++ b/fixco_custom/views/account_move_line.xml @@ -1,16 +1,17 @@ <?xml version="1.0" encoding="UTF-8" ?> <odoo> <data> -<record id="view_move_line_tree_gl_invoice_mp" model="ir.ui.view"> - <field name="name">account.move.line.tree.gl.invoice.marketplace</field> - <field name="model">account.move.line</field> - <field name="inherit_id" ref="account.view_move_line_tree_grouped_general"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='name']" position="after"> - <field name="invoice_marketplace" optional="hide"/> - </xpath> - </field> -</record> + <record id="view_move_line_tree_gl_invoice_mp" model="ir.ui.view"> + <field name="name">account.move.line.tree.gl.invoice.marketplace</field> + <field name="model">account.move.line</field> + <field name="inherit_id" ref="account.view_move_line_tree_grouped_general"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='name']" position="after"> + <field name="invoice_marketplace" optional="hide"/> + <field name="faktur_pajak" optional="hide"/> + </xpath> + </field> + </record> </data> <data> <record id="action_gl_reconcile_server" model="ir.actions.server"> diff --git a/fixco_custom/views/account_payment.xml b/fixco_custom/views/account_payment.xml index c291281..a0af30b 100644 --- a/fixco_custom/views/account_payment.xml +++ b/fixco_custom/views/account_payment.xml @@ -11,5 +11,13 @@ </button> </field> </record> + + <record id="action_reset_to_draft" model="ir.actions.server"> + <field name="name">Reset to Draft</field> + <field name="model_id" ref="account.model_account_payment" /> + <field name="binding_model_id" ref="account.model_account_payment" /> + <field name="state">code</field> + <field name="code">action = records.action_multi_reset_to_draft()</field> + </record> </data> </odoo> diff --git a/fixco_custom/views/stock_inventory.xml b/fixco_custom/views/stock_inventory.xml index 89c058e..a343db3 100644 --- a/fixco_custom/views/stock_inventory.xml +++ b/fixco_custom/views/stock_inventory.xml @@ -6,10 +6,6 @@ <field name="model">stock.inventory</field> <field name="inherit_id" ref="stock.view_inventory_form"/> <field name="arch" type="xml"> - <header> - <button name="action_approve" string="Approve" type="object" - class="btn-primary" attrs="{'invisible': [('adjusment_type', 'not in', ['out'])]}"/> - </header> <xpath expr="//field[@name='location_ids']" position="after"> <field name="number" readonly="1"/> <field name="adjusment_type" /> |
