Melya template + Confirmed
This commit is contained in:
@@ -85,7 +85,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<button name="handle_invoice_exception" icon="tryton-forward"/>
|
||||
<button name="handle_shipment_exception" icon="tryton-forward"/>
|
||||
<button name="confirm" icon="tryton-ok"/>
|
||||
<button name="process"/>
|
||||
<button name="process" invisible="1"/>
|
||||
<button name="manual_invoice" icon="tryton-forward"/>
|
||||
</group>
|
||||
<field name="party_lang" invisible="1" colspan="6"/>
|
||||
|
||||
@@ -889,6 +889,86 @@ class Sale(metaclass=PoolMeta):
|
||||
parts.append(self.incoterm_location.country.name)
|
||||
return ' '.join(parts)
|
||||
|
||||
@staticmethod
|
||||
def _get_report_bank_account_number(account):
|
||||
if not account:
|
||||
return ''
|
||||
numbers = list(getattr(account, 'numbers', []) or [])
|
||||
for number in numbers:
|
||||
if getattr(number, 'type', None) == 'iban' and getattr(number, 'number', None):
|
||||
return number.number or ''
|
||||
for number in numbers:
|
||||
if getattr(number, 'number', None):
|
||||
return number.number or ''
|
||||
return ''
|
||||
|
||||
@staticmethod
|
||||
def _get_report_bank_swift(account):
|
||||
bank = getattr(account, 'bank', None) if account else None
|
||||
return getattr(bank, 'bic', None) or ''
|
||||
|
||||
@staticmethod
|
||||
def _get_report_bank_address(account):
|
||||
bank = getattr(account, 'bank', None) if account else None
|
||||
party = getattr(bank, 'party', None) if bank else None
|
||||
address_get = getattr(party, 'address_get', None) if party else None
|
||||
if callable(address_get):
|
||||
return address_get()
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _get_report_bank_party_name(account):
|
||||
bank = getattr(account, 'bank', None) if account else None
|
||||
party = getattr(bank, 'party', None) if bank else None
|
||||
address = Sale._get_report_bank_address(account)
|
||||
return (
|
||||
getattr(address, 'party_full_name', None)
|
||||
or getattr(address, 'party_name', None)
|
||||
or getattr(party, 'rec_name', None)
|
||||
or getattr(bank, 'rec_name', None)
|
||||
or '')
|
||||
|
||||
@staticmethod
|
||||
def _get_report_bank_address_line(account):
|
||||
address = Sale._get_report_bank_address(account)
|
||||
if not address:
|
||||
return ''
|
||||
city_line = ' '.join(filter(None, [
|
||||
getattr(address, 'postal_code', None),
|
||||
getattr(address, 'city', None),
|
||||
]))
|
||||
lines = [
|
||||
getattr(address, 'name', None),
|
||||
getattr(address, 'street', None),
|
||||
city_line,
|
||||
]
|
||||
return ' '.join(line.strip() for line in lines if line and line.strip())
|
||||
|
||||
@property
|
||||
def report_melya_bank_name(self):
|
||||
return self._get_report_bank_party_name(self.our_bank_account)
|
||||
|
||||
@property
|
||||
def report_melya_bank_address(self):
|
||||
return self._get_report_bank_address_line(self.our_bank_account)
|
||||
|
||||
@property
|
||||
def report_melya_bank_iban(self):
|
||||
return self._get_report_bank_account_number(self.our_bank_account)
|
||||
|
||||
@property
|
||||
def report_melya_bank_swift(self):
|
||||
return self._get_report_bank_swift(self.our_bank_account)
|
||||
|
||||
@property
|
||||
def report_melya_bank_account_line(self):
|
||||
parts = []
|
||||
if self.report_melya_bank_iban:
|
||||
parts.append('IBAN : %s' % self.report_melya_bank_iban)
|
||||
if self.report_melya_bank_swift:
|
||||
parts.append('Swift Code: %s' % self.report_melya_bank_swift)
|
||||
return ', '.join(parts)
|
||||
|
||||
@property
|
||||
def report_packing(self):
|
||||
nb_packing = 0
|
||||
|
||||
@@ -4465,6 +4465,42 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
invoice.report_melya_bank_account_line,
|
||||
'IBAN : CH36 0021 5215 2487 7461 D, Swift Code: UBSWCHZH80A')
|
||||
|
||||
def test_sale_melya_bank_uses_our_bank_account(self):
|
||||
'sale_melya bank block uses the sale company bank account'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
address = Mock(
|
||||
party_full_name='UBS SWITZERLAND AG',
|
||||
name='Case Postale',
|
||||
street='',
|
||||
postal_code='CH-1211 Geneve 2',
|
||||
city='',
|
||||
)
|
||||
party = Mock(
|
||||
rec_name='UBS SWITZERLAND AG',
|
||||
address_get=Mock(return_value=address),
|
||||
)
|
||||
bank = Mock(party=party, bic='UBSWCHZH80A')
|
||||
account = Mock(
|
||||
bank=bank,
|
||||
numbers=[Mock(type='iban', number='CH36 0021 5215 2487 7461 D')],
|
||||
)
|
||||
|
||||
sale = Sale()
|
||||
sale.our_bank_account = account
|
||||
|
||||
self.assertEqual(sale.report_melya_bank_name, 'UBS SWITZERLAND AG')
|
||||
self.assertEqual(
|
||||
sale.report_melya_bank_address,
|
||||
'Case Postale CH-1211 Geneve 2')
|
||||
self.assertEqual(
|
||||
sale.report_melya_bank_iban,
|
||||
'CH36 0021 5215 2487 7461 D')
|
||||
self.assertEqual(sale.report_melya_bank_swift, 'UBSWCHZH80A')
|
||||
self.assertEqual(
|
||||
sale.report_melya_bank_account_line,
|
||||
'IBAN : CH36 0021 5215 2487 7461 D, Swift Code: UBSWCHZH80A')
|
||||
|
||||
def test_invoice_melya_maturity_date_uses_lines_to_pay(self):
|
||||
'invoice_melya maturity date uses the earliest line to pay maturity'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
@@ -82,7 +82,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<button name="handle_invoice_exception" icon="tryton-forward"/>
|
||||
<button name="handle_shipment_exception" icon="tryton-forward"/>
|
||||
<button name="confirm" icon="tryton-ok"/>
|
||||
<button name="process"/>
|
||||
<button name="process" invisible="1"/>
|
||||
<button name="manual_invoice" icon="tryton-forward"/>
|
||||
</group>
|
||||
<field name="party_lang" invisible="1" colspan="6"/>
|
||||
|
||||
@@ -878,7 +878,7 @@
|
||||
<style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1">
|
||||
<style:footer>
|
||||
<text:p text:style-name="P1">VAT NR. – NOT SUBJECT TO VAT IN SWITZERLAND</text:p>
|
||||
<text:p text:style-name="P2"><text:tab/>We certify this invoice authentic and definitive<text:tab/>Page <text:page-number text:select-page="current">2</text:page-number>/<text:page-count>2</text:page-count></text:p>
|
||||
<text:p text:style-name="P2"><text:tab/>We certify this invoice authentic and definitive<text:tab/>Page <text:page-number text:select-page="current">1</text:page-number>/<text:page-count>3</text:page-count></text:p>
|
||||
</style:footer>
|
||||
</style:master-page>
|
||||
</office:master-styles>
|
||||
@@ -1849,9 +1849,9 @@
|
||||
<text:p text:style-name="P5"/>
|
||||
<text:p text:style-name="P10">PAYMENT TERMS:<text:tab/><text:placeholder text:placeholder-type="text"><sale.payment_term.description if sale.payment_term else ''></text:placeholder></text:p>
|
||||
<text:p text:style-name="P5"/>
|
||||
<text:p text:style-name="P11">BANK DETAILS:<text:tab/><text:tab/>UBS SWITZERLAND AG</text:p>
|
||||
<text:p text:style-name="P11"><text:tab/><text:tab/><text:tab/>Case Postale CH-1211 Geneve 2</text:p>
|
||||
<text:p text:style-name="P11"><text:tab/><text:tab/><text:tab/>IBAN : CH36 0021 5215 2487 7461 D, Swift Code: UBSWCHZH80A</text:p>
|
||||
<text:p text:style-name="P11">BANK DETAILS:<text:tab/><text:tab/><text:placeholder text:placeholder-type="text"><sale.report_melya_bank_name></text:placeholder></text:p>
|
||||
<text:p text:style-name="P11"><text:tab/><text:tab/><text:tab/><text:placeholder text:placeholder-type="text"><sale.report_melya_bank_address></text:placeholder></text:p>
|
||||
<text:p text:style-name="P11"><text:tab/><text:tab/><text:tab/><text:placeholder text:placeholder-type="text"><sale.report_melya_bank_account_line></text:placeholder></text:p>
|
||||
<text:p text:style-name="P5"/>
|
||||
<text:p text:style-name="P5"/>
|
||||
<text:p text:style-name="P5">DELIVERY IS SUBJECT TO THE DELIVERY BY OUR SUPPLIER.</text:p>
|
||||
@@ -1868,4 +1868,4 @@
|
||||
<text:p text:style-name="Standard"><text:placeholder text:placeholder-type="text"></for></text:placeholder></text:p>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document>
|
||||
</office:document>
|
||||
|
||||
@@ -99,7 +99,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<button name="handle_invoice_exception" icon="tryton-forward"/>
|
||||
<button name="handle_shipment_exception" icon="tryton-forward"/>
|
||||
<button name="confirm" icon="tryton-forward"/>
|
||||
<button name="process"/>
|
||||
<button name="process" invisible="1"/>
|
||||
<button name="manual_invoice" icon="tryton-forward"/>
|
||||
<button name="manual_shipment" icon="tryton-forward"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user