changeset 7132c833c6a3 in modules/sale_complaint:default
details:
https://hg.tryton.org/modules/sale_complaint?cmd=changeset&node=7132c833c6a3
description:
Add employee on complaint for some states
issue11771
review431731004
diffstat:
CHANGELOG | 1 +
complaint.py | 30 +++++++++++++++++++++++++++++-
view/complaint_form.xml | 19 +++++++++++++++----
3 files changed, 45 insertions(+), 5 deletions(-)
diffs (144 lines):
diff -r ea6a6a9b72a5 -r 7132c833c6a3 CHANGELOG
--- a/CHANGELOG Sun Oct 09 18:57:51 2022 +0200
+++ b/CHANGELOG Sun Oct 09 19:01:25 2022 +0200
@@ -1,3 +1,4 @@
+* Add employee on complaint for some states
* Remove address on complaint
Version 6.4.0 - 2022-05-02
diff -r ea6a6a9b72a5 -r 7132c833c6a3 complaint.py
--- a/complaint.py Sun Oct 09 18:57:51 2022 +0200
+++ b/complaint.py Sun Oct 09 19:01:25 2022 +0200
@@ -10,6 +10,8 @@
from trytond.model import (
DeactivableMixin, ModelSQL, ModelView, Workflow, fields)
from trytond.model.exceptions import AccessError
+from trytond.modules.company.model import (
+ employee_field, reset_employee, set_employee)
from trytond.modules.currency.fields import Monetary
from trytond.modules.product import price_digits
from trytond.pool import Pool
@@ -50,7 +52,6 @@
states={
'readonly': _states['readonly'] | Eval('origin'),
})
- employee = fields.Many2One('company.employee', 'Employee', states=_states)
type = fields.Many2One('sale.complaint.type', 'Type', required=True,
states=_states)
origin = fields.Reference('Origin', selection='get_origin',
@@ -105,6 +106,18 @@
| (If(~Eval('origin_id', 0), 0, Eval('origin_id', 0)) <= 0)),
},
depends={'origin_model'})
+ submitted_by = employee_field(
+ "Submitted By",
+ states=['waiting', 'approved', 'rejected', 'done', 'cancelled'])
+ approved_by = employee_field(
+ "Approved By",
+ states=['approved', 'rejected', 'done', 'cancelled'])
+ rejected_by = employee_field(
+ "Rejected By",
+ states=['approved', 'rejected', 'done', 'cancelled'])
+ cancelled_by = employee_field(
+ "Cancelled By",
+ states=['cancelled'])
state = fields.Selection([
('draft', 'Draft'),
('waiting', 'Waiting'),
@@ -177,6 +190,11 @@
and not table_h.column_exist('number')):
table_h.column_rename('reference', 'number')
+ # Migration from 6.4: rename employee into submitted_by
+ if (table_h.column_exist('employee')
+ and not table_h.column_exist('submitted_by')):
+ table_h.column_rename('employee', 'submitted_by')
+
super(Complaint, cls).__register__(module_name)
@classmethod
@@ -271,6 +289,10 @@
else:
default = default.copy()
default.setdefault('number', None)
+ default.setdefault('submitted_by')
+ default.setdefault('approved_by')
+ default.setdefault('rejected_by')
+ default.setdefault('cancelled_by')
return super(Complaint, cls).copy(complaints, default=default)
@classmethod
@@ -285,24 +307,29 @@
@classmethod
@ModelView.button
@Workflow.transition('cancelled')
+ @set_employee('cancelled_by')
def cancel(cls, complaints):
pass
@classmethod
@ModelView.button
@Workflow.transition('draft')
+ @reset_employee(
+ 'submitted_by', 'approved_by', 'rejected_by', 'cancelled_by')
def draft(cls, complaints):
pass
@classmethod
@ModelView.button
@Workflow.transition('waiting')
+ @set_employee('submitted_by')
def wait(cls, complaints):
pass
@classmethod
@ModelView.button
@Workflow.transition('approved')
+ @set_employee('approved_by')
def approve(cls, complaints):
pool = Pool()
Configuration = pool.get('sale.configuration')
@@ -317,6 +344,7 @@
@classmethod
@ModelView.button
@Workflow.transition('rejected')
+ @set_employee('rejected_by')
def reject(cls, complaints):
pass
diff -r ea6a6a9b72a5 -r 7132c833c6a3 view/complaint_form.xml
--- a/view/complaint_form.xml Sun Oct 09 18:57:51 2022 +0200
+++ b/view/complaint_form.xml Sun Oct 09 19:01:25 2022 +0200
@@ -13,10 +13,6 @@
<field name="date"/>
<notebook>
<page string="Complaint" id="complaint">
- <label name="company"/>
- <field name="company"/>
- <label name="employee"/>
- <field name="employee"/>
<label name="type"/>
<field name="type" widget="selection"/>
<label name="origin"/>
@@ -26,6 +22,21 @@
<field name="description" colspan="2"/>
<field name="actions" colspan="2"/>
</page>
+ <page string="Other Info" id="other">
+ <label name="company"/>
+ <field name="company"/>
+ <newline/>
+
+ <label name="submitted_by"/>
+ <field name="submitted_by"/>
+ <label name="cancelled_by"/>
+ <field name="cancelled_by"/>
+
+ <label name="approved_by"/>
+ <field name="approved_by"/>
+ <label name="rejected_by"/>
+ <field name="rejected_by"/>
+ </page>
</notebook>
<label name="state"/>
<field name="state"/>