Add employee on document for some states
issue8969 review276621002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add employee on purchases for some states
|
||||
* Add contact and invoice party on purchase
|
||||
|
||||
Version 5.4.0 - 2019-11-04
|
||||
|
||||
+20
-8
@@ -22,6 +22,8 @@ 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 PurchaseQuotationError, PartyLocationError
|
||||
@@ -80,14 +82,6 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
reference = fields.Char('Reference', select=True)
|
||||
description = fields.Char('Description', size=None, states=_states,
|
||||
depends=_depends)
|
||||
state = fields.Selection([
|
||||
('draft', "Draft"),
|
||||
('quotation', "Quotation"),
|
||||
('confirmed', "Confirmed"),
|
||||
('processing', "Processing"),
|
||||
('done', "Done"),
|
||||
('cancel', "Canceled"),
|
||||
], "State", readonly=True, required=True)
|
||||
purchase_date = fields.Date('Purchase Date',
|
||||
states={
|
||||
'readonly': ~Eval('state').in_(['draft', 'quotation']),
|
||||
@@ -204,6 +198,21 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
'get_shipment_returns', searcher='search_shipment_returns')
|
||||
moves = fields.One2Many('stock.move', 'purchase', 'Moves', readonly=True)
|
||||
|
||||
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)
|
||||
|
||||
del _states, _depends
|
||||
|
||||
@classmethod
|
||||
@@ -836,12 +845,14 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
@reset_employee('quoted_by', 'confirmed_by')
|
||||
def draft(cls, purchases):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('quotation')
|
||||
@set_employee('quoted_by')
|
||||
def quote(cls, purchases):
|
||||
for purchase in purchases:
|
||||
purchase.check_for_quotation()
|
||||
@@ -850,6 +861,7 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('confirmed')
|
||||
@set_employee('confirmed_by')
|
||||
def confirm(cls, purchases):
|
||||
pool = Pool()
|
||||
Configuration = pool.get('purchase.configuration')
|
||||
|
||||
@@ -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(
|
||||
@@ -155,9 +170,13 @@ Purchase 5 products::
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.untaxed_amount, purchase.tax_amount, purchase.total_amount
|
||||
(Decimal('25.00'), Decimal('2.50'), Decimal('27.50'))
|
||||
>>> purchase.quoted_by == employee
|
||||
True
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.untaxed_amount, purchase.tax_amount, purchase.total_amount
|
||||
(Decimal('25.00'), Decimal('2.50'), Decimal('27.50'))
|
||||
>>> purchase.confirmed_by == employee
|
||||
True
|
||||
>>> purchase.state
|
||||
'processing'
|
||||
>>> purchase.shipment_state
|
||||
|
||||
@@ -54,6 +54,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="invoice_method"/>
|
||||
<label name="delivery_date"/>
|
||||
<field name="delivery_date"/>
|
||||
<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