diff --git a/__init__.py b/__init__.py index cdbdcbe..bd15190 100644 --- a/__init__.py +++ b/__init__.py @@ -3,6 +3,7 @@ from trytond.pool import Pool from . import party from . import stock +from . import sale def register(): @@ -10,4 +11,5 @@ def register(): party.Party, party.BancopalPriceList, stock.Move, + sale.Sale, module='sale_bancopal', type_='model') diff --git a/sale.py b/sale.py new file mode 100644 index 0000000..19a4967 --- /dev/null +++ b/sale.py @@ -0,0 +1,16 @@ +# The COPYRIGHT file at the top level of this repository contains the full +# copyright notices and license terms. +from trytond.pool import PoolMeta + +__all__ = ['Sale'] + + +class Sale: + __name__ = 'sale.sale' + __metaclass__ = PoolMeta + + def on_change_party(self): + super(Sale, self).on_change_party() + if self.party and self.party.bancopal and \ + self.party.bancopal_price_list: + self.price_list = self.party.bancopal_price_list diff --git a/tests/scenario_sale_bancopal.rst b/tests/scenario_sale_bancopal.rst index 5e200fd..299d71b 100644 --- a/tests/scenario_sale_bancopal.rst +++ b/tests/scenario_sale_bancopal.rst @@ -110,4 +110,12 @@ Discount applied when quantity is 10:: >>> move.quantity = 10 >>> move.unit_price - Decimal('5.0000') \ No newline at end of file + Decimal('5.0000') + +Create a sale:: + + >>> Sale = Model.get('sale.sale') + >>> sale = Sale() + >>> sale.party = customer + >>> sale.price_list == price_list + True \ No newline at end of file