proforma template

This commit is contained in:
2026-04-23 10:46:36 +02:00
parent 228ee07a9c
commit a1486175f2
5 changed files with 66 additions and 27 deletions

View File

@@ -1,8 +1,8 @@
# Template Properties - Purchase Trade
Statut: `draft`
Version: `v0.2`
Derniere mise a jour: `2026-04-07`
Version: `v0.3`
Derniere mise a jour: `2026-04-23`
## 1) Objectif
@@ -351,6 +351,21 @@ Usage typique:
- base de travail pour les templates de type `sale_ict.fodt`
- source de verite de plusieurs proprietes du bridge facture
### Proprietes specifiques `sale_melya.fodt`
- `report_melya_proforma_number`
- Usage: valeur affichee dans `Proforma Nr`
- Source de verite: deal lie via `report_deal`, fallback numero de vente
- `report_melya_buyer_address`
- Usage: bloc buyer avec nom long et adresse
- Source de verite: `sale.invoice_address.full_address` avec le contexte
`address_with_party`
- `report_melya_incoterm`
- Usage: ligne `DELIVERY TERMS`
- Source de verite: incoterm code + lieu incoterm + pays du lieu incoterm
## 7) Proprietes utiles deja presentes sur `purchase.purchase`
Source code: `modules/purchase_trade/purchase.py`

View File

@@ -348,8 +348,7 @@ class Purchase(metaclass=PoolMeta):
return [account.id for account in self.party.bank_accounts]
return []
@fields.depends('company', '_parent_company.party',
'_parent_company.party.bank_accounts')
@fields.depends('company', '_parent_company.party')
def on_change_with_our_bank_accounts(self, name=None):
if (self.company and self.company.party
and self.company.party.bank_accounts):
@@ -359,7 +358,7 @@ class Purchase(metaclass=PoolMeta):
@fields.depends(
'company', 'party', 'invoice_party', 'payment_term', 'lines',
'bank_account', 'our_bank_account', '_parent_party.bank_accounts',
'_parent_company.party', '_parent_company.party.bank_accounts')
'_parent_company.party')
def on_change_party(self):
super().on_change_party()
self.bank_account = self._get_default_bank_account()
@@ -367,13 +366,13 @@ class Purchase(metaclass=PoolMeta):
@fields.depends(
'party', 'company', 'currency', '_parent_party.bank_accounts',
'_parent_company.party', '_parent_company.party.bank_accounts')
'_parent_company.party')
def on_change_currency(self):
self.bank_account = self._get_default_bank_account()
self.our_bank_account = self._get_default_our_bank_account()
@fields.depends('company', 'currency', 'our_bank_account',
'_parent_company.party', '_parent_company.party.bank_accounts')
'_parent_company.party')
def on_change_company(self):
super().on_change_company()
self.our_bank_account = self._get_default_our_bank_account()

View File

@@ -312,8 +312,7 @@ class Sale(metaclass=PoolMeta):
return [account.id for account in self.party.bank_accounts]
return []
@fields.depends('company', '_parent_company.party',
'_parent_company.party.bank_accounts')
@fields.depends('company', '_parent_company.party')
def on_change_with_our_bank_accounts(self, name=None):
if (self.company and self.company.party
and self.company.party.bank_accounts):
@@ -323,8 +322,7 @@ class Sale(metaclass=PoolMeta):
@fields.depends(
'company', 'party', 'invoice_party', 'shipment_party', 'warehouse',
'payment_term', 'lines', 'bank_account', 'our_bank_account',
'_parent_party.bank_accounts', '_parent_company.party',
'_parent_company.party.bank_accounts')
'_parent_party.bank_accounts', '_parent_company.party')
def on_change_party(self):
super().on_change_party()
self.bank_account = self._get_default_bank_account()
@@ -332,13 +330,13 @@ class Sale(metaclass=PoolMeta):
@fields.depends(
'party', 'company', 'currency', '_parent_party.bank_accounts',
'_parent_company.party', '_parent_company.party.bank_accounts')
'_parent_company.party')
def on_change_currency(self):
self.bank_account = self._get_default_bank_account()
self.our_bank_account = self._get_default_our_bank_account()
@fields.depends('company', 'currency', 'our_bank_account',
'_parent_company.party', '_parent_company.party.bank_accounts')
'_parent_company.party')
def on_change_company(self):
super().on_change_company()
self.our_bank_account = self._get_default_our_bank_account()
@@ -719,12 +717,39 @@ class Sale(metaclass=PoolMeta):
@property
def report_deal(self):
if self.lines and self.lines[0].lots and len(self.lines[0].lots)>1:
return self.lines[0].lots[1].line.purchase.number + ' ' + self.number
else:
''
@property
if self.lines and self.lines[0].lots and len(self.lines[0].lots) > 1:
purchase = getattr(getattr(self.lines[0].lots[1], 'line', None),
'purchase', None)
purchase_number = getattr(purchase, 'number', None)
if purchase_number and self.number:
return purchase_number + ' ' + self.number
return purchase_number or self.number or ''
return ''
@property
def report_melya_proforma_number(self):
return self.report_deal or self.full_number or ''
@property
def report_melya_buyer_address(self):
if not self.invoice_address:
return ''
with Transaction().set_context(address_with_party=True):
return self.invoice_address.full_address
@property
def report_melya_incoterm(self):
parts = []
if self.incoterm and self.incoterm.code:
parts.append(self.incoterm.code)
if self.incoterm_location:
if self.incoterm_location.party_name:
parts.append(self.incoterm_location.party_name)
if self.incoterm_location.country:
parts.append(self.incoterm_location.country.name)
return ' '.join(parts)
@property
def report_packing(self):
nb_packing = 0
unit = ''

View File

@@ -9,8 +9,9 @@ depends:
stock
res
lot
document_incoming
incoterm
document_incoming
incoterm
bank
xml:
purchase.xml
sale.xml

View File

@@ -1721,12 +1721,11 @@
</draw:image>
</draw:frame><text:tab/><text:tab/><text:span text:style-name="T1">PROFORMA INVOICE</text:span></text:p>
<text:p text:style-name="Standard"><text:tab/><text:tab/><text:span text:style-name="T10">Proforma Nr:<text:tab/><text:tab/><text:tab/>Date:</text:span></text:p>
<text:p text:style-name="Standard"><text:tab/><text:tab/><text:span text:style-name="T35"><text:placeholder text:placeholder-type="text">&lt;sale.report_deal&gt;</text:placeholder></text:span><text:tab/><text:tab/><text:tab/><text:span text:style-name="T35"><text:placeholder text:placeholder-type="text">&lt;format_date(sale.sale_date, sale.party.lang) if sale.sale_date else &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="Standard"><text:tab/><text:tab/><text:span text:style-name="T35"><text:placeholder text:placeholder-type="text">&lt;sale.report_melya_proforma_number&gt;</text:placeholder></text:span><text:tab/><text:tab/><text:tab/><text:span text:style-name="T35"><text:placeholder text:placeholder-type="text">&lt;format_date(sale.sale_date, sale.party.lang) if sale.sale_date else &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:span text:style-name="T10">Buyer:</text:span></text:p>
<text:p text:style-name="Standard"><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:span text:style-name="T33"><text:placeholder text:placeholder-type="text">&lt;sale.party.rec_name&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P1"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;line in sale.report_address.splitlines()&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P1"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;line in sale.report_melya_buyer_address.splitlines()&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P1"><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:tab/><text:placeholder text:placeholder-type="text">&lt;line&gt;</text:placeholder></text:p>
<text:p text:style-name="P1"><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
<text:p text:style-name="Standard"/>
@@ -1763,8 +1762,8 @@
<text:p text:style-name="P25" loext:marker-style-name="T39"/>
<text:p text:style-name="P24" loext:marker-style-name="T39"/>
<text:p text:style-name="P24" loext:marker-style-name="T39"/>
<text:p text:style-name="P39" loext:marker-style-name="T26"><text:span text:style-name="T26"><text:s text:c="2"/></text:span><text:span text:style-name="T42"><text:placeholder text:placeholder-type="text">&lt;sale.report_product_name or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P30" loext:marker-style-name="T26"><text:span text:style-name="T42"><text:placeholder text:placeholder-type="text">&lt;sale.report_product_description or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P39" loext:marker-style-name="T26"><text:span text:style-name="T42"><text:placeholder text:placeholder-type="text">&lt;sale.report_product_name or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P39" loext:marker-style-name="T26"><text:span text:style-name="T42"><text:placeholder text:placeholder-type="text">&lt;sale.report_product_description or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P27" loext:marker-style-name="T42"><text:span text:style-name="T42"><text:s/></text:span></text:p>
</table:table-cell>
<table:table-cell table:style-name="Tableau1.B2" office:value-type="string">
@@ -1799,7 +1798,7 @@
<text:p text:style-name="P3"/>
<text:p text:style-name="P3">TRANSPORTATION BY:<text:tab/>VESSEL</text:p>
<text:p text:style-name="P3"/>
<text:p text:style-name="P8">DELIVERY TERMS:<text:tab/><text:placeholder text:placeholder-type="text">&lt;sale.incoterm.code if sale.incoterm else &apos;&apos;&gt;</text:placeholder> <text:s/><text:placeholder text:placeholder-type="text">&lt;sale.incoterm_location.party_name if sale.incoterm_location else &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P8">DELIVERY TERMS:<text:tab/><text:placeholder text:placeholder-type="text">&lt;sale.report_melya_incoterm&gt;</text:placeholder></text:p>
<text:p text:style-name="P2"/>
<text:p text:style-name="P7">PAYMENT TERMS:<text:tab/><text:placeholder text:placeholder-type="text">&lt;sale.payment_term.description if sale.payment_term else &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P2"/>