diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-27 14:21:50 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-27 14:21:50 +0700 |
| commit | 3a47b67ee123af57411557bf0eebeaa6e2ddc0a3 (patch) | |
| tree | 67175d4a7ee46e0036209effd782687dcdb2bbfd /fixco_custom | |
| parent | 149d3f03ffa0a99d032cb96fba711888d23f378c (diff) | |
<Miqdad> add context on creating invoices
Diffstat (limited to 'fixco_custom')
| -rw-r--r-- | fixco_custom/models/account_move.py | 5 | ||||
| -rwxr-xr-x | fixco_custom/models/sale.py | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py index 519c8d5..60e0b86 100644 --- a/fixco_custom/models/account_move.py +++ b/fixco_custom/models/account_move.py @@ -322,8 +322,9 @@ class AccountMove(models.Model): if entry.move_type in ['out_invoice', 'out_refund']: 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 + if self.env.context.get('force_picking_date') == True: + if entry.picking_id and entry.picking_id.date_done: + entry.invoice_date = entry.picking_id.date_done res = super(AccountMove, self).action_post() diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 0bd3f5d..90cc581 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -51,7 +51,7 @@ class SaleOrder(models.Model): created_invoices = self.env['account.move'] for order in self: # Create invoice for this SO only - invoice = order.with_context(default_invoice_origin=order.name)._create_invoices(final=True) + invoice = order.with_context(default_invoice_origin=order.name, force_picking_date=True)._create_invoices(final=True) invoice.action_post() invoice.invoice_date = invoice.picking_id.date_done created_invoices += invoice |
