diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2026-02-23 09:56:11 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2026-02-23 09:56:11 +0700 |
| commit | a74cf187f1e25edc18b7718c53af9f74554cfed8 (patch) | |
| tree | b5ec5cd2fd68a7dea6f0026ea869063f670f53f4 /fixco_custom/models | |
| parent | 8bba994b80718a078ec24ade3b1cdf03eac8c0ff (diff) | |
| parent | 233662316ed9b108271f5f4aacb1fcc0b05be63a (diff) | |
Merge branch 'main' of bitbucket.org:altafixco/fixco-addons
pull
Diffstat (limited to 'fixco_custom/models')
| -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 |
5 files changed, 60 insertions, 24 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 |
