Fix multivalue implementation.

This commit refs #6311
This commit is contained in:
Sergio Morillo 2018-11-21 13:10:57 +01:00
parent 0f3ea35d39
commit f75d52a8b1
2 changed files with 30 additions and 3 deletions

View File

@ -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"

View File

@ -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():