mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
Add backport commision issue6322 + issue6501
This commit is contained in:
parent
fa90a39b59
commit
673d4c9c78
85
commission-issue6322-issue6501.diff
Normal file
85
commission-issue6322-issue6501.diff
Normal file
|
@ -0,0 +1,85 @@
|
|||
diff -r 37acb1bd3076 trytond/trytond/modules/commission/commission.py
|
||||
--- a/trytond/trytond/modules/commission/commission.py Wed Jan 04 00:27:44 2017 +0100
|
||||
+++ b/trytond/trytond/modules/commission/commission.py Tue Jun 06 11:01:07 2017 +0200
|
||||
@@ -143,7 +143,12 @@
|
||||
'Compute commission amount for the amount'
|
||||
if pattern is None:
|
||||
pattern = {}
|
||||
- pattern['product'] = product.id if product else None
|
||||
+ if product:
|
||||
+ pattern['categories'] = [c.id for c in product.categories]
|
||||
+ pattern['product'] = product.id
|
||||
+ else:
|
||||
+ pattern['categories'] = []
|
||||
+ pattern['product'] = None
|
||||
context = self.get_context_formula(amount, product)
|
||||
for line in self.lines:
|
||||
if line.match(pattern):
|
||||
@@ -155,6 +160,8 @@
|
||||
__name__ = 'commission.plan.line'
|
||||
plan = fields.Many2One('commission.plan', 'Plan', required=True,
|
||||
ondelete='CASCADE')
|
||||
+ category = fields.Many2One(
|
||||
+ 'product.category', "Category", ondelete='CASCADE')
|
||||
product = fields.Many2One('product.product', 'Product')
|
||||
sequence = fields.Integer('Sequence')
|
||||
formula = fields.Char('Formula', required=True,
|
||||
@@ -204,6 +211,15 @@
|
||||
context.setdefault('functions', {})['Decimal'] = Decimal
|
||||
return simple_eval(decistmt(self.formula), **context)
|
||||
|
||||
+ def match(self, pattern):
|
||||
+ if 'categories' in pattern:
|
||||
+ pattern = pattern.copy()
|
||||
+ categories = pattern.pop('categories')
|
||||
+ if (self.category is not None
|
||||
+ and self.category.id not in categories):
|
||||
+ return False
|
||||
+ return super(PlanLines, self).match(pattern)
|
||||
+
|
||||
|
||||
class Commission(ModelSQL, ModelView):
|
||||
'Commission'
|
||||
diff -r 37acb1bd3076 trytond/trytond/modules/commission/view/plan_line_form.xml
|
||||
--- a/trytond/trytond/modules/commission/view/plan_line_form.xml Wed Jan 04 00:27:44 2017 +0100
|
||||
+++ b/trytond/trytond/modules/commission/view/plan_line_form.xml Tue Jun 06 11:01:07 2017 +0200
|
||||
@@ -4,12 +4,12 @@
|
||||
<form string="Commission Plan Line">
|
||||
<label name="plan"/>
|
||||
<field name="plan"/>
|
||||
- <newline/>
|
||||
+ <label name="sequence"/>
|
||||
+ <field name="sequence"/>
|
||||
+ <label name="category"/>
|
||||
+ <field name="category"/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
- <label name="sequence"/>
|
||||
- <field name="sequence"/>
|
||||
- <newline/>
|
||||
- <label name="formula"/>
|
||||
+ <separator id="formula" colspan="4"/>
|
||||
<field name="formula" colspan="3"/>
|
||||
</form>
|
||||
diff -r 37acb1bd3076 trytond/trytond/modules/commission/view/plan_line_list.xml
|
||||
--- a/trytond/trytond/modules/commission/view/plan_line_list.xml Wed Jan 04 00:27:44 2017 +0100
|
||||
+++ b/trytond/trytond/modules/commission/view/plan_line_list.xml Tue Jun 06 11:01:07 2017 +0200
|
||||
@@ -4,6 +4,7 @@
|
||||
<tree string="Commission Plan Lines">
|
||||
<field name="plan"/>
|
||||
<field name="sequence"/>
|
||||
+ <field name="category"/>
|
||||
<field name="product"/>
|
||||
<field name="formula"/>
|
||||
</tree>
|
||||
diff -r 37acb1bd3076 trytond/trytond/modules/commission/view/plan_line_list_sequence.xml
|
||||
--- a/trytond/trytond/modules/commission/view/plan_line_list_sequence.xml Wed Jan 04 00:27:44 2017 +0100
|
||||
+++ b/trytond/trytond/modules/commission/view/plan_line_list_sequence.xml Tue Jun 06 11:01:07 2017 +0200
|
||||
@@ -2,6 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree string="Commission Plan Lines" sequence="sequence">
|
||||
+ <field name="category"/>
|
||||
<field name="product"/>
|
||||
<field name="formula"/>
|
||||
</tree>
|
Loading…
Reference in a new issue