Deal nb
This commit is contained in:
@@ -481,6 +481,16 @@ class Invoice(metaclass=PoolMeta):
|
||||
def _get_report_trade(self):
|
||||
return self._get_report_sale() or self._get_report_purchase()
|
||||
|
||||
def _get_report_deal_sale(self):
|
||||
sale = self._get_report_sale()
|
||||
if sale:
|
||||
return sale
|
||||
for lot in self._get_report_invoice_lots() or []:
|
||||
line = getattr(lot, 'sale_line', None)
|
||||
sale = getattr(line, 'sale', None) if line else None
|
||||
if sale:
|
||||
return sale
|
||||
|
||||
def _get_report_purchase_line(self):
|
||||
purchase = self._get_report_purchase()
|
||||
if purchase and purchase.lines:
|
||||
@@ -761,6 +771,10 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_contract_number(self):
|
||||
sale = self._get_report_deal_sale()
|
||||
deal = getattr(sale, 'report_deal', None) if sale else None
|
||||
if deal:
|
||||
return deal.replace(' ', '/')
|
||||
trade = self._get_report_trade()
|
||||
if trade and trade.full_number:
|
||||
return trade.full_number
|
||||
|
||||
@@ -2710,6 +2710,16 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(invoice.report_product_name, 'COTTON UPLAND')
|
||||
self.assertEqual(invoice.report_product_description, 'RAW WHITE COTTON')
|
||||
|
||||
def test_invoice_melya_reference_uses_sale_deal_number(self):
|
||||
'invoice_melya Reference uses the sale deal number'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
invoice = Invoice()
|
||||
sale = Mock(report_deal='P-12 S-34')
|
||||
invoice._get_report_deal_sale = Mock(return_value=sale)
|
||||
|
||||
self.assertEqual(invoice.report_contract_number, 'P-12/S-34')
|
||||
|
||||
def test_contract_factory_uses_one_line_per_selected_source(self):
|
||||
'matched multi-lot contract creation keeps one generated line per source lot'
|
||||
contract_detail = Mock(quantity=Decimal('2000'))
|
||||
|
||||
Reference in New Issue
Block a user