FIX tests
This commit is contained in:
parent
34af9bce3b
commit
df48ea5e76
20
sale.py
20
sale.py
|
@ -243,15 +243,15 @@ class SaleRuleAction(ModelSQL, ModelView):
|
||||||
'sale_forbidden': ('You cannot make this sale because of %s.'),
|
'sale_forbidden': ('You cannot make this sale because of %s.'),
|
||||||
})
|
})
|
||||||
|
|
||||||
@fields.depends('account')
|
@fields.depends('rule')
|
||||||
def on_change_with_currency_digits(self, name=None):
|
def on_change_with_currency_digits(self, name=None):
|
||||||
return self.rule.shop and self.rule.shop.currency.digits or 2
|
return (self.rule and self.rule.shop and
|
||||||
|
self.rule.shop.currency.digits or 2)
|
||||||
|
|
||||||
@fields.depends('rule')
|
@fields.depends('rule')
|
||||||
def on_change_action_type(self):
|
def on_change_action_type(self):
|
||||||
if self.rule:
|
self.currency_digits = (self.rule and self.rule.shop
|
||||||
self.currency_digits = (self.rule.shop
|
and self.rule.shop.currency.digits or 2)
|
||||||
and self.rule.shop.currency.digits or 2)
|
|
||||||
|
|
||||||
def get_rec_name(self, name):
|
def get_rec_name(self, name):
|
||||||
for selection in self._fields['action_type'].selection:
|
for selection in self._fields['action_type'].selection:
|
||||||
|
@ -344,15 +344,15 @@ class SaleRuleCondition(ModelSQL, ModelView):
|
||||||
super(SaleRuleCondition, cls).__setup__()
|
super(SaleRuleCondition, cls).__setup__()
|
||||||
cls._order.insert(0, ('sequence', 'ASC'))
|
cls._order.insert(0, ('sequence', 'ASC'))
|
||||||
|
|
||||||
@fields.depends('account')
|
@fields.depends('rule')
|
||||||
def on_change_with_currency_digits(self, name=None):
|
def on_change_with_currency_digits(self, name=None):
|
||||||
return self.rule.shop and self.rule.shop.currency.digits or 2
|
return (self.rule and self.rule.shop and
|
||||||
|
self.rule.shop.currency.digits or 2)
|
||||||
|
|
||||||
@fields.depends('rule')
|
@fields.depends('rule')
|
||||||
def on_change_criteria(self):
|
def on_change_criteria(self):
|
||||||
if self.rule:
|
self.currency_digits = (self.rule and self.rule.shop
|
||||||
self.currency_digits = (self.rule.shop
|
and self.rule.shop.currency.digits or 2)
|
||||||
and self.rule.shop.currency.digits or 2)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_condition():
|
def default_condition():
|
||||||
|
|
10
sale.xml
10
sale.xml
|
@ -43,6 +43,16 @@ copyright notices and license terms. -->
|
||||||
action="act_sale_rule"
|
action="act_sale_rule"
|
||||||
id="menu_sale_rule" icon="tryton-list"/>
|
id="menu_sale_rule" icon="tryton-list"/>
|
||||||
|
|
||||||
|
<record model="ir.model.button" id="apply_rules_button">
|
||||||
|
<field name="name">apply_rules</field>
|
||||||
|
<field name="string">Apply Rules</field>
|
||||||
|
<field name="model" search="[('model', '=', 'sale.sale')]"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.model.button-res.group" id="apply_rules_button_group_sale">
|
||||||
|
<field name="button" ref="apply_rules_button"/>
|
||||||
|
<field name="group" ref="sale.group_sale"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- sale.rule.condition -->
|
<!-- sale.rule.condition -->
|
||||||
<record model="ir.ui.view" id="sale_rule_condition_tree_view">
|
<record model="ir.ui.view" id="sale_rule_condition_tree_view">
|
||||||
<field name="model">sale.rule.condition</field>
|
<field name="model">sale.rule.condition</field>
|
||||||
|
|
|
@ -7,6 +7,7 @@ Imports::
|
||||||
>>> import datetime
|
>>> import datetime
|
||||||
>>> from decimal import Decimal
|
>>> from decimal import Decimal
|
||||||
>>> from proteus import config, Model, Wizard
|
>>> from proteus import config, Model, Wizard
|
||||||
|
>>> from trytond.tests.tools import activate_modules
|
||||||
>>> from trytond.modules.company.tests.tools import create_company, \
|
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||||
... get_company
|
... get_company
|
||||||
>>> from trytond.modules.account.tests.tools import create_chart, \
|
>>> from trytond.modules.account.tests.tools import create_chart, \
|
||||||
|
@ -14,19 +15,9 @@ Imports::
|
||||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||||
... create_payment_term
|
... create_payment_term
|
||||||
|
|
||||||
Configure::
|
|
||||||
|
|
||||||
>>> config = config.set_trytond()
|
|
||||||
>>> config.pool.test = True
|
|
||||||
|
|
||||||
Install sale_rule::
|
Install sale_rule::
|
||||||
|
|
||||||
>>> Module = Model.get('ir.module')
|
>>> config = activate_modules('sale_rule')
|
||||||
>>> module, = Module.find([
|
|
||||||
... ('name', '=', 'sale_rule'),
|
|
||||||
... ])
|
|
||||||
>>> module.click('install')
|
|
||||||
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
|
|
||||||
|
|
||||||
Create company::
|
Create company::
|
||||||
|
|
||||||
|
@ -63,13 +54,14 @@ Create products::
|
||||||
>>> template.salable = True
|
>>> template.salable = True
|
||||||
>>> template.lead_time = datetime.timedelta(0)
|
>>> template.lead_time = datetime.timedelta(0)
|
||||||
>>> template.list_price = Decimal('20')
|
>>> template.list_price = Decimal('20')
|
||||||
>>> template.cost_price = Decimal('8')
|
|
||||||
>>> template.account_revenue = revenue
|
>>> template.account_revenue = revenue
|
||||||
>>> template.save()
|
>>> template.save()
|
||||||
>>> product1 = Product()
|
>>> product1 = Product()
|
||||||
>>> product1.template = template
|
>>> product1.template = template
|
||||||
|
>>> product1.cost_price = Decimal('8')
|
||||||
>>> product1.save()
|
>>> product1.save()
|
||||||
>>> product2 = Product()
|
>>> product2 = Product()
|
||||||
|
>>> product2.cost_price = Decimal('8')
|
||||||
>>> product2.template = template
|
>>> product2.template = template
|
||||||
>>> product2.save()
|
>>> product2.save()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=4.1.0
|
version=4.8.0
|
||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
res
|
res
|
||||||
|
|
Loading…
Reference in New Issue