parent
0f3ea35d39
commit
f75d52a8b1
8
party.py
8
party.py
|
@ -30,6 +30,14 @@ class Party:
|
|||
return pool.get('party.party.invoice_to')
|
||||
return super(Party, cls).multivalue_model(field)
|
||||
|
||||
def multivalue_record(self, field, **pattern):
|
||||
Value = self.multivalue_model(field)
|
||||
if Value.__name__ == 'party.party.invoice_to':
|
||||
pattern = pattern.copy()
|
||||
pattern['party'] = self
|
||||
return Value(**pattern)
|
||||
return super(Party, self).multivalue_record(field, **pattern)
|
||||
|
||||
|
||||
class PartyInvoiceTo(ModelSQL, CompanyValueMixin):
|
||||
"Party Invoice to"
|
||||
|
|
|
@ -1,16 +1,35 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
import unittest
|
||||
from trytond.pool import Pool
|
||||
import trytond.tests.test_tryton
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class TestCase(ModuleTestCase):
|
||||
"""Test module"""
|
||||
module = 'account_invoice_party_invoice_to'
|
||||
|
||||
def setUp(self):
|
||||
super(TestCase, self).setUp()
|
||||
@with_transaction()
|
||||
def test_party(self):
|
||||
'Test configuration accounts are used as fallback on party'
|
||||
pool = Pool()
|
||||
Party = pool.get('party.party')
|
||||
|
||||
party1 = Party(name='Party to pay')
|
||||
party1.save()
|
||||
self.assertIsNone(party1.customer_to_invoice)
|
||||
self.assertIsNone(party1.supplier_to_invoice)
|
||||
|
||||
party2 = Party(name='Party to receive')
|
||||
party2.save()
|
||||
|
||||
party = Party(name='Party')
|
||||
party.customer_to_invoice = party1
|
||||
party.supplier_to_invoice = party2
|
||||
party.save()
|
||||
self.assertEqual(party.customer_to_invoice, party1)
|
||||
self.assertEqual(party.supplier_to_invoice, party2)
|
||||
|
||||
|
||||
def suite():
|
||||
|
|
Loading…
Reference in New Issue