This commit is contained in:
gsinghpal
2026-04-27 00:11:18 -04:00
parent d9f58b9851
commit f08f328688
116 changed files with 9891 additions and 359 deletions

View File

@@ -5,7 +5,7 @@
{
'name': 'Fusion Plating — Invoicing',
'version': '19.0.3.0.0',
'version': '19.0.3.1.0',
'category': 'Manufacturing/Plating',
'summary': 'Invoice strategy engine with deposit, progress billing, net terms, COD/prepay, and account holds.',
'description': """

View File

@@ -19,25 +19,23 @@ class FpDelivery(models.Model):
def action_mark_delivered(self):
res = super().action_mark_delivered()
SaleOrder = self.env['sale.order']
MrpProduction = self.env['mrp.production']
# Sub 11 — MRP gone; resolve via delivery.job_ref → fp.job.name → fp.job.origin.
Job = self.env['fp.job'] if 'fp.job' in self.env else None
for delivery in self:
# Resolve the sale order via delivery.job_ref → MO.name → MO.origin
so = False
if delivery.job_ref:
mo = MrpProduction.search(
if delivery.job_ref and Job is not None:
job = Job.sudo().search(
[('name', '=', delivery.job_ref)], limit=1,
)
if mo and mo.origin:
if job and job.origin:
so = SaleOrder.search(
[('name', '=', mo.origin)], limit=1,
[('name', '=', job.origin)], limit=1,
)
if not so:
# Fallback: find by partner + recently-confirmed with matching strategy
continue
strategy = so.x_fc_invoice_strategy
if strategy not in ('progress', 'net_terms'):
continue
# Skip if already billed in full
if so.invoice_status == 'invoiced':
continue
so._create_final_balance_invoice()