Add employee on document for some states
issue8969 review276621002
This commit is contained in:
1 parent
7b4715a6db
commit
2ea47f1d88
4 files changed
+46
-9
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add employee on sales for some states
|
||||
* Add contact and invoice party on sale
|
||||
* Add salable products menu entry
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@ from trytond.pool import Pool
|
||||
|
||||
from trytond.modules.account.tax import TaxableMixin
|
||||
from trytond.modules.account_product.exceptions import AccountError
|
||||
from trytond.modules.company.model import (
|
||||
employee_field, set_employee, reset_employee)
|
||||
from trytond.modules.product import price_digits
|
||||
|
||||
from .exceptions import (
|
||||
SaleValidationError, SaleQuotationError, PartyLocationError)
|
||||
|
||||
@@ -73,14 +76,6 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
depends=['state'])
|
||||
state = fields.Selection([
|
||||
('draft', "Draft"),
|
||||
('quotation', "Quotation"),
|
||||
('confirmed', "Confirmed"),
|
||||
('processing', "Processing"),
|
||||
('done', "Done"),
|
||||
('cancel', "Canceled"),
|
||||
], "State", readonly=True, required=True)
|
||||
sale_date = fields.Date('Sale Date',
|
||||
states={
|
||||
'readonly': ~Eval('state').in_(['draft', 'quotation']),
|
||||
@@ -229,6 +224,21 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
},
|
||||
depends=['state'])
|
||||
|
||||
quoted_by = employee_field(
|
||||
"Quoted By",
|
||||
states=['quotation', 'confirmed', 'processing', 'done', 'cancel'])
|
||||
confirmed_by = employee_field(
|
||||
"Confirmed By",
|
||||
states=['confirmed', 'processing', 'done', 'cancel'])
|
||||
state = fields.Selection([
|
||||
('draft', "Draft"),
|
||||
('quotation', "Quotation"),
|
||||
('confirmed', "Confirmed"),
|
||||
('processing', "Processing"),
|
||||
('done', "Done"),
|
||||
('cancel', "Canceled"),
|
||||
], "State", readonly=True, required=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Sale, cls).__setup__()
|
||||
@@ -871,12 +881,14 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
@reset_employee('quoted_by', 'confirmed_by')
|
||||
def draft(cls, sales):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('quotation')
|
||||
@set_employee('quoted_by')
|
||||
def quote(cls, sales):
|
||||
for sale in sales:
|
||||
sale.check_for_quotation()
|
||||
@@ -885,6 +897,7 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('confirmed')
|
||||
@set_employee('confirmed_by')
|
||||
def confirm(cls, sales):
|
||||
pool = Pool()
|
||||
Configuration = pool.get('sale.configuration')
|
||||
|
||||
+20
-1
@@ -9,7 +9,7 @@ Imports::
|
||||
>>> from decimal import Decimal
|
||||
>>> from operator import attrgetter
|
||||
>>> from proteus import Model, Wizard, Report
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
>>> from trytond.tests.tools import activate_modules, set_user
|
||||
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||
... get_company
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
|
||||
@@ -27,6 +27,21 @@ Create company::
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Set employee::
|
||||
|
||||
>>> User = Model.get('res.user')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> Employee = Model.get('company.employee')
|
||||
>>> employee_party = Party(name="Employee")
|
||||
>>> employee_party.save()
|
||||
>>> employee = Employee(party=employee_party)
|
||||
>>> employee.save()
|
||||
>>> user = User(config.user)
|
||||
>>> user.employees.append(employee)
|
||||
>>> user.employee = employee
|
||||
>>> user.save()
|
||||
>>> set_user(user.id)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
@@ -148,9 +163,13 @@ Sale 5 products::
|
||||
>>> sale.click('quote')
|
||||
>>> sale.untaxed_amount, sale.tax_amount, sale.total_amount
|
||||
(Decimal('50.00'), Decimal('5.00'), Decimal('55.00'))
|
||||
>>> sale.quoted_by == employee
|
||||
True
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.untaxed_amount, sale.tax_amount, sale.total_amount
|
||||
(Decimal('50.00'), Decimal('5.00'), Decimal('55.00'))
|
||||
>>> sale.confirmed_by == employee
|
||||
True
|
||||
>>> sale.state
|
||||
'processing'
|
||||
>>> sale.shipment_state
|
||||
|
||||
@@ -64,6 +64,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="invoice_method"/>
|
||||
<label name="shipment_method"/>
|
||||
<field name="shipment_method"/>
|
||||
<label name="quoted_by"/>
|
||||
<field name="quoted_by"/>
|
||||
<label name="confirmed_by"/>
|
||||
<field name="confirmed_by"/>
|
||||
<separator name="comment" colspan="4"/>
|
||||
<field name="comment" colspan="4"/>
|
||||
</page>
|
||||
|
||||
Reference in new issue
Block a user