Fill tax rule pattern of web shop with countries
When account_tax_rule_country is activated, the pattern must be filled with from_country and to_country to compute the right tax. Closes #13223 (grafted from 1f4f2778d399c214b93ff41ac9e11e826f7c6724) --HG-- branch : 7.0
This commit is contained in:
@@ -28,3 +28,6 @@ def register():
|
||||
Pool.register(
|
||||
product.Image,
|
||||
module='web_shop', type_='model', depends=['product_image'])
|
||||
Pool.register(
|
||||
web.Shop_TaxRuleCountry,
|
||||
module='web_shop', type_='model', depends=['account_tax_rule_country'])
|
||||
|
||||
@@ -51,6 +51,7 @@ for dep in info.get('depends', []):
|
||||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = [
|
||||
get_require_version('trytond_account_tax_rule_country'),
|
||||
get_require_version('trytond_product_attribute'),
|
||||
get_require_version('trytond_product_image'),
|
||||
]
|
||||
|
||||
@@ -8,7 +8,8 @@ from trytond.tests.test_tryton import ModuleTestCase
|
||||
class WebShopTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test Web Shop module'
|
||||
module = 'web_shop'
|
||||
extras = ['product_attribute', 'product_image']
|
||||
extras = [
|
||||
'account_tax_rule_country', 'product_attribute', 'product_image']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
|
||||
@@ -10,6 +10,7 @@ depends:
|
||||
stock
|
||||
web_user
|
||||
extras_depend:
|
||||
account_tax_rule_country
|
||||
product_attribute
|
||||
product_image
|
||||
xml:
|
||||
|
||||
@@ -252,6 +252,22 @@ class Shop(DeactivableMixin, ModelSQL, ModelView):
|
||||
return sale
|
||||
|
||||
|
||||
class Shop_TaxRuleCountry(metaclass=PoolMeta):
|
||||
__name__ = 'web.shop'
|
||||
|
||||
def get_products(self, pattern=None):
|
||||
pattern = pattern.copy() if pattern is not None else {}
|
||||
if (self.warehouse
|
||||
and self.warehouse.address
|
||||
and self.warehouse.address.country):
|
||||
pattern.setdefault(
|
||||
'from_country', self.warehouse.address.country.id)
|
||||
else:
|
||||
pattern.setdefault('from_country')
|
||||
pattern.setdefault('to_country')
|
||||
return super().get_products(pattern=pattern)
|
||||
|
||||
|
||||
class Shop_Warehouse(ModelSQL):
|
||||
"Web Shop - Warehouse"
|
||||
__name__ = 'web.shop-stock.location'
|
||||
|
||||
Reference in New Issue
Block a user