changes
This commit is contained in:
@@ -165,6 +165,40 @@ class FpDirectOrderWizard(models.Model):
|
||||
"""Default pricelist = company's default. Re-resolved on partner pick."""
|
||||
return self.env.company.partner_id.property_product_pricelist.id or False
|
||||
|
||||
@api.model
|
||||
def _fp_default_terms_and_conditions(self):
|
||||
"""Seed Terms & Conditions from the Accounting default — same source
|
||||
as the standard sale.order.note field.
|
||||
|
||||
Respects the `account.use_invoice_terms` system parameter (toggled
|
||||
from Settings → Invoicing → Default Terms & Conditions). Strips HTML
|
||||
tags defensively since Odoo's rich-text editor sometimes leaks
|
||||
markup into the plain `invoice_terms` field; the wizard field is
|
||||
Text and must not store raw markup.
|
||||
"""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
if not ICP.get_param('account.use_invoice_terms'):
|
||||
return False
|
||||
company = self.env.company
|
||||
raw = (
|
||||
(company.invoice_terms or '').strip()
|
||||
or (getattr(company, 'invoice_terms_html', False) or '').strip()
|
||||
)
|
||||
if not raw:
|
||||
return False
|
||||
# Defensive HTML strip — works whether the source was clean plain
|
||||
# text, a real html field, or a "plain" field polluted by the
|
||||
# rich-text editor (entech case 2026-05-27).
|
||||
if '<' in raw and '>' in raw:
|
||||
try:
|
||||
from lxml import html as lxml_html
|
||||
raw = lxml_html.fromstring(raw).text_content().strip()
|
||||
except Exception:
|
||||
# Last-ditch regex fallback — no lxml, malformed html, etc.
|
||||
import re
|
||||
raw = re.sub(r'<[^>]+>', '', raw).strip()
|
||||
return raw or False
|
||||
|
||||
# ---- Express Orders: auto-apply order recipe to all lines ----
|
||||
@api.onchange('material_process')
|
||||
def _onchange_material_process_apply_to_lines(self):
|
||||
@@ -273,9 +307,10 @@ class FpDirectOrderWizard(models.Model):
|
||||
# so the existing data preserves its customer-facing semantic.
|
||||
terms_and_conditions = fields.Text(
|
||||
string='Terms & Conditions',
|
||||
default=lambda self: self._fp_default_terms_and_conditions(),
|
||||
help='Customer-facing terms — prints on quote / SO / invoice. '
|
||||
'Seeded from res.company.invoice_terms_html with partner-level '
|
||||
'override via res.partner.invoice_terms.',
|
||||
'Seeded from the Accounting default terms '
|
||||
'(Settings → Invoicing → Default Terms & Conditions).',
|
||||
)
|
||||
internal_notes = fields.Text(
|
||||
string='Order-Level Internal Notes',
|
||||
|
||||
Reference in New Issue
Block a user