feat(numbering): block direct invoice creation + wire account.move into mixin
Customer invoices (out_invoice / out_refund) can only be created via sale.order._create_invoices() or with an invoice_origin matching an existing SO. Applies to ALL users including admins. Once created, the move's name is derived from the SO's parent number: IN-30000, IN-30000-02, CN-30000, ... Pre-existing portal-job link on action_post() preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -296,6 +296,17 @@ class SaleOrder(models.Model):
|
||||
) % {'job': job.name, 'err': exc})
|
||||
return result
|
||||
|
||||
def _create_invoices(self, grouped=False, final=False, date=None):
|
||||
"""Set fp_from_so_invoice=True so account.move.create() allows
|
||||
the customer-invoice creation (the direct-creation block is
|
||||
bypassed via this context flag). Also lets the parent-numbered
|
||||
mixin find the originating SO without depending on invoice_origin.
|
||||
"""
|
||||
return super(SaleOrder, self.with_context(
|
||||
fp_from_so_invoice=True,
|
||||
fp_invoice_source_so_id=self.id if len(self) == 1 else False,
|
||||
))._create_invoices(grouped=grouped, final=final, date=date)
|
||||
|
||||
def _fp_resolve_recipe_for_line(self, line):
|
||||
"""4-tier recipe resolution. Used BOTH for grouping (Task 6
|
||||
recipe-driven WO splits) AND for the per-job vals construction.
|
||||
|
||||
Reference in New Issue
Block a user