Master purchase indent
This commit is contained in:
parent
1d4dae4cb4
commit
887dec3ed5
@ -5,4 +5,3 @@
|
||||
from . import res_branch
|
||||
from . import ir_branch_company
|
||||
from . import res_partner
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flectra import api, fields, models
|
||||
# from flectra.exceptions import ValidationError
|
||||
|
||||
|
||||
class Company(models.Model):
|
||||
@ -22,6 +23,7 @@ class Company(models.Model):
|
||||
'company_id': company.id})
|
||||
return company
|
||||
|
||||
|
||||
class ResBranch(models.Model):
|
||||
_name = "res.branch"
|
||||
|
||||
@ -45,7 +47,8 @@ class ResBranch(models.Model):
|
||||
phone = fields.Char()
|
||||
mobile = fields.Char()
|
||||
|
||||
_sql_constraints = [('branch_code_company_uniq', 'unique (code,company_id)',
|
||||
_sql_constraints = [('branch_code_company_uniq',
|
||||
'unique (code,company_id)',
|
||||
'The branch code must be unique per company!')]
|
||||
|
||||
@api.model
|
||||
@ -109,13 +112,23 @@ class Users(models.Model):
|
||||
default=_get_branch,
|
||||
domain="[('company_id','=',company_id)"
|
||||
"]")
|
||||
branches_count = fields.Integer(compute='_compute_branches_count',
|
||||
string="Number of Companies",
|
||||
default=_branches_count)
|
||||
branches_count = fields.Integer(
|
||||
compute='_compute_branches_count',
|
||||
string="Number of Companies", default=_branches_count)
|
||||
|
||||
# To do : Check with all base module test cases
|
||||
# @api.multi
|
||||
# @api.constrains('default_branch_id', 'branch_ids')
|
||||
# def _check_branches(self):
|
||||
# for user in self:
|
||||
# if user.branch_ids \
|
||||
# and user.default_branch_id not in user.branch_ids:
|
||||
# raise ValidationError(_('The selected Default Branch (%s) '
|
||||
# 'is not in the Branches!') % (
|
||||
# user.default_branch_id.name))
|
||||
|
||||
@api.multi
|
||||
def _compute_branches_count(self):
|
||||
branches_count = self._branches_count()
|
||||
for user in self:
|
||||
user.branches_count = branches_count
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flectra import api, fields, models
|
||||
from flectra import api, models
|
||||
|
||||
|
||||
class Partner(models.Model):
|
||||
_name = "res.partner"
|
||||
@ -17,6 +18,3 @@ class Partner(models.Model):
|
||||
self.branch_id.with_context(ctx).write(branch_vals)
|
||||
result = super(Partner, self).write(vals)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ from flectra.tests.common import TransactionCase
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestMultiBranch(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestMultiBranch, self).setUp()
|
||||
@ -14,10 +15,11 @@ class TestMultiBranch(TransactionCase):
|
||||
self.branch0 = self.env.ref('base_branch_company.data_branch_1')
|
||||
self.branch1 = self.env.ref('base_branch_company.data_branch_2')
|
||||
|
||||
self.user_1 = self.create_user(self.main_company, 'user_1', self.branch0,
|
||||
[self.branch0, self.branch1])
|
||||
self.user_2 = self.create_user(self.main_company, 'user_2', self.branch1,
|
||||
[self.branch1])
|
||||
self.user_1 = self.create_user(
|
||||
self.main_company, 'user_1', self.branch0,
|
||||
[self.branch0, self.branch1])
|
||||
self.user_2 = self.create_user(
|
||||
self.main_company, 'user_2', self.branch1, [self.branch1])
|
||||
|
||||
self.model_id = \
|
||||
self.env['ir.model'].search([('model', '=', 'res.partner')])
|
||||
@ -45,7 +47,7 @@ class TestMultiBranch(TransactionCase):
|
||||
def create_user(self, main_company, user_name, branch_id, branch_ids):
|
||||
data = {
|
||||
'company_ids': [(4, main_company.id)],
|
||||
'branch_ids': [(4, branch_id.id) for branch_id in branch_ids],
|
||||
'branch_ids': [(4, branch.id) for branch in branch_ids],
|
||||
'company_id': main_company.id,
|
||||
'default_branch_id': branch_id.id,
|
||||
'login': user_name,
|
||||
@ -57,24 +59,17 @@ class TestMultiBranch(TransactionCase):
|
||||
user_obj = self.env['res.users'].create(data)
|
||||
return user_obj
|
||||
|
||||
|
||||
def test_user_authentication(self):
|
||||
partner = self.partner_obj.sudo(self.user_1.id).search(
|
||||
[('id', '=', self.branch_partner1.id),
|
||||
('branch_id', '=', self.branch0.id)])
|
||||
self.assertNotEqual(partner.ids, [], 'Test User have access to '
|
||||
'Branch %s' % self.branch0.name)
|
||||
self.assertNotEqual(partner.ids, [],
|
||||
'Test User have access to Branch %s' %
|
||||
self.branch0.name)
|
||||
|
||||
partner = self.partner_obj.sudo(self.user_2.id).search(
|
||||
[('id', '=', self.branch_partner0.id),
|
||||
('branch_id', '=', self.branch0.id)])
|
||||
self.assertEqual(partner.ids, [],
|
||||
'Test User should not have access to '
|
||||
'Branch %s' % self.branch0.name)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'Test User should not have access to Branch %s' %
|
||||
self.branch0.name)
|
||||
|
@ -90,7 +90,7 @@
|
||||
<xpath expr="//page[@name='access_rights']/group[1]" position="after">
|
||||
<group groups="base_branch_company.group_multi_branch">
|
||||
<group string="Allowed Branches" attrs="{'invisible': [('branches_count', '<=', 1)]}">
|
||||
<field name="default_branch_id"/>
|
||||
<field name="default_branch_id" required="1"/>
|
||||
<field name="branch_ids" widget="many2many_tags"/>
|
||||
<field string="Branches count" name="branches_count" invisible="1"/>
|
||||
</group>
|
||||
|
@ -70,7 +70,11 @@ class PurchaseOrder(models.Model):
|
||||
def _default_picking_type(self):
|
||||
type_obj = self.env['stock.picking.type']
|
||||
company_id = self.env.context.get('company_id') or self.env.user.company_id.id
|
||||
types = type_obj.search([('code', '=', 'incoming'), ('warehouse_id.company_id', '=', company_id)])
|
||||
branch_id = self.env.context.get(
|
||||
'branch_id') or self.env.user.default_branch_id.id
|
||||
types = type_obj.search([('code', '=', 'incoming'),
|
||||
('warehouse_id.company_id', '=', company_id),
|
||||
('warehouse_id.branch_id', '=', branch_id)])
|
||||
if not types:
|
||||
types = type_obj.search([('code', '=', 'incoming'), ('warehouse_id', '=', False)])
|
||||
return types[:1]
|
||||
|
@ -15,6 +15,7 @@
|
||||
<field name="product_qty">2</field>
|
||||
<field name="remaining_qty">2.0</field>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="branch_id" ref="base_branch_company.data_branch_2"/>
|
||||
</record>
|
||||
|
||||
<function model="purchase.indent" name="action_confirm"
|
||||
|
@ -204,7 +204,7 @@ msgid "Group By"
|
||||
msgstr ""
|
||||
|
||||
#. module: purchase_indent
|
||||
#: model:ir.model.fields,field_description:purchase_indent.field_purchase_indent_intend_history_ids
|
||||
#: model:ir.model.fields,field_description:purchase_indent.field_purchase_indent_indent_history_ids
|
||||
#: model:ir.ui.view,arch_db:purchase_indent.view_purchase_indent_form
|
||||
msgid "History"
|
||||
msgstr ""
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from flectra.exceptions import Warning, AccessError
|
||||
from flectra.exceptions import Warning, AccessError, ValidationError
|
||||
from flectra.tools.misc import formatLang
|
||||
|
||||
import flectra.addons.decimal_precision as dp
|
||||
@ -167,6 +167,7 @@ class PurchaseRequisition(models.Model):
|
||||
|
||||
purchase_indent_ids = fields.Many2many(
|
||||
'purchase.indent', string='Purchase Indent')
|
||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
||||
|
||||
@api.multi
|
||||
def action_draft(self):
|
||||
@ -205,18 +206,21 @@ class PurchaseRequisitionLine(models.Model):
|
||||
'purchase.indent.line', 'Purchase Indent Line Ref')
|
||||
purchase_indent_ids = fields.Many2many(
|
||||
'purchase.indent', string='Purchase Indent')
|
||||
branch_id = fields.Many2one(related='requisition_id.branch_id',
|
||||
string='Branch', store=True)
|
||||
|
||||
|
||||
class PurchaseIndent(models.Model):
|
||||
_name = 'purchase.indent'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin',
|
||||
'ir.branch.company.mixin']
|
||||
_description = "Purchase Indent"
|
||||
|
||||
@api.multi
|
||||
def _compute_order_count(self):
|
||||
po_list = []
|
||||
pa_list = []
|
||||
for history_id in self.intend_history_ids:
|
||||
for history_id in self.indent_history_ids:
|
||||
if history_id.order_id:
|
||||
po_list.append(history_id.order_id.id)
|
||||
elif history_id.purchase_requisition_id:
|
||||
@ -260,7 +264,7 @@ class PurchaseIndent(models.Model):
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner', related='user_id.partner_id',
|
||||
string="Partner", track_visibility='onchange')
|
||||
intend_history_ids = fields.One2many(
|
||||
indent_history_ids = fields.One2many(
|
||||
'purchase.indent.history', 'purchase_indent_id', 'History')
|
||||
purchase_order_count = fields.Integer(
|
||||
compute='_compute_order_count', string='# of Purchase Order')
|
||||
@ -280,20 +284,34 @@ class PurchaseIndent(models.Model):
|
||||
help="Technical field used to display the Drop Ship Address",
|
||||
readonly=True)
|
||||
|
||||
@api.constrains('company_id', 'branch_id')
|
||||
def _check_company(self):
|
||||
for order in self:
|
||||
if order.branch_id \
|
||||
and order.company_id != order.branch_id.company_id:
|
||||
raise ValidationError(
|
||||
_('Configuration Error of Company:\n'
|
||||
'The Purchase Indent Company (%s) and '
|
||||
'the Company (%s) of Branch must '
|
||||
'be the same company!') % (
|
||||
order.company_id.name,
|
||||
order.branch_id.company_id.name)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def set_qty_state_cancel(self, purchase_order_id=False,
|
||||
purchase_agreement_id=False):
|
||||
intend_history_ids = []
|
||||
indent_history_ids = []
|
||||
indent_line_obj = self.env['purchase.indent.line']
|
||||
if purchase_order_id:
|
||||
intend_history_ids = self.env['purchase.indent.history'].search([
|
||||
indent_history_ids = self.env['purchase.indent.history'].search([
|
||||
('order_id', '=', purchase_order_id.id),
|
||||
('purchase_requisition_id', '=', False)])
|
||||
elif purchase_agreement_id:
|
||||
intend_history_ids = self.env['purchase.indent.history'].search([
|
||||
indent_history_ids = self.env['purchase.indent.history'].search([
|
||||
('order_id', '=', False),
|
||||
('purchase_requisition_id', '=', purchase_agreement_id.id)])
|
||||
for history_id in intend_history_ids:
|
||||
for history_id in indent_history_ids:
|
||||
indent_line_id = indent_line_obj.sudo().search([
|
||||
('product_id', '=', history_id.product_id.id),
|
||||
('purchase_indent_id', '=', history_id.purchase_indent_id.id)])
|
||||
@ -307,16 +325,16 @@ class PurchaseIndent(models.Model):
|
||||
def set_qty_state_confirm(self, purchase_order_id=False,
|
||||
purchase_agreement_id=False):
|
||||
indent_line_obj = self.env['purchase.indent.line']
|
||||
intend_history_ids = []
|
||||
indent_history_ids = []
|
||||
if purchase_order_id:
|
||||
intend_history_ids = self.env['purchase.indent.history'].search([
|
||||
indent_history_ids = self.env['purchase.indent.history'].search([
|
||||
('order_id', '=', purchase_order_id.id),
|
||||
('state', '=', 'Cancelled')])
|
||||
elif purchase_agreement_id:
|
||||
intend_history_ids = self.env['purchase.indent.history'].search([
|
||||
indent_history_ids = self.env['purchase.indent.history'].search([
|
||||
('purchase_requisition_id', '=', purchase_agreement_id.id),
|
||||
('state', '=', 'Cancelled')])
|
||||
for history_id in intend_history_ids:
|
||||
for history_id in indent_history_ids:
|
||||
indent_line_id = indent_line_obj.sudo().search([
|
||||
('product_id', '=', history_id.product_id.id),
|
||||
('purchase_indent_id', '=', history_id.purchase_indent_id.id)])
|
||||
@ -442,7 +460,7 @@ class PurchaseIndent(models.Model):
|
||||
@api.multi
|
||||
def get_purchase_order_list(self):
|
||||
order_list = [
|
||||
history_id.order_id.id for history_id in self.intend_history_ids]
|
||||
history_id.order_id.id for history_id in self.indent_history_ids]
|
||||
return {
|
||||
'name': 'Purchase Orders',
|
||||
'type': 'ir.actions.act_window',
|
||||
@ -455,7 +473,7 @@ class PurchaseIndent(models.Model):
|
||||
@api.multi
|
||||
def get_purchase_agreement_list(self):
|
||||
pr_list = [history_id.purchase_requisition_id.id
|
||||
for history_id in self.intend_history_ids]
|
||||
for history_id in self.indent_history_ids]
|
||||
return {
|
||||
'name': 'Purchase Agreements',
|
||||
'type': 'ir.actions.act_window',
|
||||
@ -528,6 +546,8 @@ class PurchaseIndentLine(models.Model):
|
||||
company_id = fields.Many2one(
|
||||
'res.company', related='purchase_indent_id.company_id',
|
||||
string='Company', store=True, readonly=True)
|
||||
branch_id = fields.Many2one(related='purchase_indent_id.branch_id',
|
||||
string='Branch', store=True)
|
||||
requisition_qty = fields.Float(
|
||||
string="Requisition Quantity",
|
||||
digits=dp.get_precision('Discount'))
|
||||
@ -599,6 +619,10 @@ class PurchaseIndentHistory(models.Model):
|
||||
self_id.product_qty - self_id.requisition_qty
|
||||
|
||||
purchase_indent_id = fields.Many2one('purchase.indent', 'Purchase Indent')
|
||||
branch_id = fields.Many2one(related='purchase_indent_id.branch_id',
|
||||
string='Branch', store=True)
|
||||
company_id = fields.Many2one(related='purchase_indent_id.company_id',
|
||||
string="Company", store=True)
|
||||
product_id = fields.Many2one(
|
||||
'product.product', string='Product',
|
||||
domain=[('purchase_ok', '=', True)],
|
||||
|
@ -54,6 +54,10 @@
|
||||
<strong>Category:</strong>
|
||||
<p t-field="o.category_id.name"/>
|
||||
</div>
|
||||
<div t-if="o.branch_id" class="col-xs-3">
|
||||
<strong>Branch:</strong>
|
||||
<p t-field="o.branch_id.name"/>
|
||||
</div>
|
||||
</div>
|
||||
<table width="100%" class="table table-striped table-bordered"
|
||||
border="1">
|
||||
|
@ -20,4 +20,26 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Multi Branch -->
|
||||
|
||||
<record model="ir.rule" id="purchase_indent_multi_branch_rule">
|
||||
<field name="name">Purchase Indent multi-branch</field>
|
||||
<field name="model_id" ref="model_purchase_indent"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">
|
||||
['|', ('branch_id', '=', False), '|', ('branch_id', '=', user.default_branch_id.id),
|
||||
('branch_id', 'in', user.branch_ids.ids)]
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="purchase_indent_line_multi_branch_rule">
|
||||
<field name="name">Purchase Indent Line multi-branch</field>
|
||||
<field name="model_id" ref="model_purchase_indent_line"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">
|
||||
['|', ('branch_id', '=', False), '|', ('branch_id', '=', user.default_branch_id.id),
|
||||
('branch_id', 'in', user.branch_ids.ids)]
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</flectra>
|
||||
|
@ -2,11 +2,9 @@
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from flectra.exceptions import Warning
|
||||
from flectra.tests.common import TransactionCase
|
||||
from flectra.tools.misc import formatLang
|
||||
|
||||
from flectra import _
|
||||
|
||||
|
||||
@ -17,22 +15,30 @@ class TestPurchaseIndent(TransactionCase):
|
||||
self.PurchaseIndent = self.env['purchase.indent']
|
||||
self.PurchaseIndentLine = self.env['purchase.indent.line']
|
||||
self.Requisition_Req = self.env['wiz.requisition.request']
|
||||
|
||||
def test_00_purchase_indent_flow(self):
|
||||
self.company_id = self.env.ref('base.main_company')
|
||||
self.branch_id = self.env.ref('base_branch_company.data_branch_2')
|
||||
self.partner_id = self.env.ref('base.res_partner_address_12')
|
||||
self.category_id = self.env.ref('product.product_category_5')
|
||||
self.product_id_1 = self.env.ref('product.product_product_24')
|
||||
self.product_id_2 = self.env.ref('product.product_product_16')
|
||||
self.product_id_3 = self.env.ref('product.consu_delivery_03')
|
||||
self.company_id = self.env.ref('base.main_company')
|
||||
self.agreement_type_id = \
|
||||
self.env.ref('purchase_requisition.type_multi')
|
||||
|
||||
purchase_indent_vals_1 = {
|
||||
purchase_indent_vals = {
|
||||
'company_id': self.company_id.id,
|
||||
'category_id': self.category_id.id,
|
||||
'request_date': datetime.today(),
|
||||
'user_id': self.env.user.id,
|
||||
'branch_id': self.branch_id.id
|
||||
}
|
||||
|
||||
self.purchase_indent_id = \
|
||||
self.PurchaseIndent.create(purchase_indent_vals)
|
||||
self.purchase_indent_id_1 = self.purchase_indent_id.copy()
|
||||
|
||||
def test_00_purchase_indent_flow(self):
|
||||
self.purchase_indent_id.write({
|
||||
'indent_line': [
|
||||
(0, 0, {
|
||||
'name': self.product_id_1.name,
|
||||
@ -46,13 +52,9 @@ class TestPurchaseIndent(TransactionCase):
|
||||
'product_qty': 15.0,
|
||||
'product_uom': self.product_id_2.uom_po_id.id,
|
||||
})],
|
||||
}
|
||||
})
|
||||
|
||||
purchase_indent_vals_2 = {
|
||||
'company_id': self.company_id.id,
|
||||
'category_id': self.category_id.id,
|
||||
'request_date': datetime.today(),
|
||||
'user_id': self.env.user.id,
|
||||
self.purchase_indent_id_1.write({
|
||||
'indent_line': [
|
||||
(0, 0, {
|
||||
'name': self.product_id_3.name,
|
||||
@ -72,31 +74,32 @@ class TestPurchaseIndent(TransactionCase):
|
||||
'product_qty': 5.0,
|
||||
'product_uom': self.product_id_2.uom_po_id.id,
|
||||
})],
|
||||
}
|
||||
self.pi = self.PurchaseIndent.create(purchase_indent_vals_1)
|
||||
self.pi_1 = self.PurchaseIndent.create(purchase_indent_vals_2)
|
||||
self.assertTrue(
|
||||
self.pi, 'Purchase Indent: no purchase indent created')
|
||||
self.assertTrue(
|
||||
self.pi_1, 'Purchase Indent: no purchase indent created')
|
||||
})
|
||||
|
||||
for line in self.pi.indent_line:
|
||||
self.assertTrue(
|
||||
self.purchase_indent_id,
|
||||
'Purchase Indent: no purchase indent created')
|
||||
self.assertTrue(
|
||||
self.purchase_indent_id_1,
|
||||
'Purchase Indent: no purchase indent created')
|
||||
|
||||
for line in self.purchase_indent_id.indent_line:
|
||||
if line.product_qty < 0:
|
||||
raise Warning(_("Quantity (%s) can not be Negative!") % (
|
||||
formatLang(self.env, line.product_qty, digits=2)))
|
||||
|
||||
for line in self.pi_1.indent_line:
|
||||
for line in self.purchase_indent_id_1.indent_line:
|
||||
if line.product_qty < 0:
|
||||
raise Warning(_("Quantity (%s) can not be Negative!") % (
|
||||
formatLang(self.env, line.product_qty, digits=2)))
|
||||
|
||||
self.pi.action_confirm()
|
||||
self.pi_1.action_confirm()
|
||||
self.purchase_indent_id.action_confirm()
|
||||
self.purchase_indent_id_1.action_confirm()
|
||||
|
||||
requisition_id = self.Requisition_Req.create({
|
||||
'category_id': self.category_id.id,
|
||||
'order_type': 'po',
|
||||
'purchase_indent_id': self.pi.id,
|
||||
'purchase_indent_id': self.purchase_indent_id.id,
|
||||
})
|
||||
requisition_id.onchange_purchase_indent_id()
|
||||
requisition_id.dummy_wiz_indent_line[0].write({'requisition_qty': 5})
|
||||
@ -106,10 +109,15 @@ class TestPurchaseIndent(TransactionCase):
|
||||
for line in requisition_id.wiz_indent_line:
|
||||
line.write({'price_unit': 100})
|
||||
requisition_id.action_create()
|
||||
logging.info('Successful: Purchase Order Created!')
|
||||
|
||||
# Cancel Purchase Order
|
||||
self.purchase_indent_id.indent_history_ids[0].order_id.button_cancel()
|
||||
|
||||
requisition_id_1 = self.Requisition_Req.create({
|
||||
'category_id': self.category_id.id,
|
||||
'order_type': 'pa',
|
||||
'purchase_indent_id': self.pi_1.id,
|
||||
'purchase_indent_id': self.purchase_indent_id_1.id,
|
||||
'requisition_type_id': self.agreement_type_id.id,
|
||||
})
|
||||
|
||||
@ -120,4 +128,4 @@ class TestPurchaseIndent(TransactionCase):
|
||||
for line in requisition_id_1.wiz_indent_line:
|
||||
line.write({'price_unit': 100})
|
||||
requisition_id_1.action_create()
|
||||
logging.info('\n\nSuccessful: Purchase Agreement Created!')
|
||||
logging.info('Successful: Purchase Agreement Created!')
|
||||
|
@ -21,8 +21,14 @@
|
||||
<field name="model">purchase.requisition</field>
|
||||
<field name="inherit_id" ref="purchase_requisition.view_purchase_requisition_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='%(purchase_requisition.action_purchase_requisition_to_so)d']" position="replace">
|
||||
<button name="%(purchase_requisition.action_purchase_requisition_to_so)d" type="action"
|
||||
string="New Quotation" class="btn-primary" context="{'default_branch_id': branch_id}"
|
||||
attrs="{'invisible': [('state', 'not in', ['in_progress', 'open'])]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='vendor_id']" position="after">
|
||||
<field name="purchase_indent_ids" widget="many2many_tags" readonly="1"/>
|
||||
<field name='branch_id' readonly="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//notebook/page/field/tree/field[@name='product_qty']" position="after">
|
||||
<field name="purchase_indent_ids" widget="many2many_tags" readonly="1"/>
|
||||
@ -41,6 +47,7 @@
|
||||
<field name="request_date"/>
|
||||
<field name="category_id"/>
|
||||
<field name="company_id"/>
|
||||
<field name="branch_id" groups="base_branch_company.group_multi_branch"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
@ -53,7 +60,7 @@
|
||||
<form string="Purchase Indent">
|
||||
<header>
|
||||
<button name="action_confirm" states="draft" string="Confirm" type="object" class="oe_highlight"/>
|
||||
<button name="%(action_wiz_requisition_request)d" states="confirm,requisition" string="Create Requisition" type="action" context="{'default_purchase_indent_id': active_id, 'default_category_id': category_id}" class="oe_highlight" groups="base.group_system,purchase.group_purchase_manager"/>
|
||||
<button name="%(action_wiz_requisition_request)d" states="confirm,requisition" string="Create Requisition" type="action" context="{'default_purchase_indent_id': active_id, 'default_category_id': category_id, 'default_branch_id': branch_id}" class="oe_highlight" groups="base.group_system,purchase.group_purchase_manager"/>
|
||||
<button name="action_cancel" states="confirm" string="Cancel" type="object"/>
|
||||
<button name="button_draft" states="cancel" string="Set to Draft" type="object"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,requisition,done" readonly="1"/>
|
||||
@ -73,8 +80,9 @@
|
||||
<group col="4">
|
||||
<field name="category_id" options="{'no_create': True}" required="1" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="request_date" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="company_id" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}" required="1"/>
|
||||
<field name="company_id" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}" required="1"/>
|
||||
<field name="user_id"/>
|
||||
<field name="branch_id" groups="base_branch_company.group_multi_branch" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="picking_type_id" domain="[('code','=','incoming')]" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="dest_address_id" groups="stock.group_stock_multi_locations" attrs="{'invisible': [('default_location_dest_id_usage', '!=', 'customer')], 'required': [('default_location_dest_id_usage', '=', 'customer')]}"/>
|
||||
<field name="default_location_dest_id_usage" invisible="1"/>
|
||||
@ -94,7 +102,7 @@
|
||||
</field>
|
||||
</page>
|
||||
<page string="History">
|
||||
<field name="intend_history_ids" readonly="1">
|
||||
<field name="indent_history_ids" readonly="1">
|
||||
<tree editable="bottom">
|
||||
<field name="product_id"/>
|
||||
<field name="state"/>
|
||||
@ -127,6 +135,7 @@
|
||||
<field name="name" string="Name" filter_domain="[('name','ilike',self)]"/>
|
||||
<field name="category_id" string="Category" filter_domain="[('category_id','ilike',self)]"/>
|
||||
<field name="user_id" string="Requestd By" filter_domain="[('user_id','ilike',self)]"/>
|
||||
<field name="branch_id" string="Branch" filter_domain="[('branch_id','ilike',self)]"/>
|
||||
<field name="state" string="State" filter_domain="[('state','ilike',self)]"/>
|
||||
<filter name="draft" string="Draft" domain="[('state','=', 'draft')]"/>
|
||||
<filter name="confirm" string="Confirm" domain="[('state','=','confirm')]"/>
|
||||
@ -135,6 +144,7 @@
|
||||
<filter name="cancel" string="Cancel" domain="[('state', '=', 'cancel')]"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Category" domain="[]" context="{'group_by':'category_id'}"/>
|
||||
<filter string="Branch" domain="[]" context="{'group_by':'branch_id'}"/>
|
||||
<filter string="State" domain="[]" context="{'group_by':'state'}"/>
|
||||
<filter string="Requestd By" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Request Date" domain="[]" context="{'group_by':'request_date'}"/>
|
||||
|
@ -13,6 +13,7 @@ class WizRequisitionRequest(models.TransientModel):
|
||||
_name = 'wiz.requisition.request'
|
||||
|
||||
purchase_indent_id = fields.Many2one('purchase.indent', 'Purchase Indent')
|
||||
branch_id = fields.Many2one('res.branch', string='Branch')
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner', 'Vendor', domain="[('supplier','=',True)]")
|
||||
wiz_indent_line = fields.One2many(
|
||||
@ -47,6 +48,7 @@ class WizRequisitionRequest(models.TransientModel):
|
||||
purchase_indent_ids = self.purchase_indent_id.search([
|
||||
('category_id', '=', self.purchase_indent_id.category_id.id),
|
||||
('state', 'in', ['confirm', 'requisition']),
|
||||
('branch_id', '=', self.purchase_indent_id.branch_id.id),
|
||||
('company_id', '=', self.purchase_indent_id.company_id.id)])
|
||||
list_data = []
|
||||
value = {}
|
||||
@ -179,14 +181,17 @@ class WizRequisitionRequest(models.TransientModel):
|
||||
vals = {
|
||||
'partner_id': self.partner_id.id,
|
||||
'state': 'draft',
|
||||
'branch_id': self.branch_id.id,
|
||||
'company_id': self.purchase_indent_id.company_id.id,
|
||||
}
|
||||
purchase_order_id = self.env['purchase.order'].create(vals)
|
||||
purchase_order_id = self.env['purchase.order'].with_context(
|
||||
{'branch_id': self.branch_id.id}).create(vals)
|
||||
else:
|
||||
vals = {
|
||||
'name': self.sudo().env['ir.sequence'].next_by_code(
|
||||
'purchase.order.requisition') or 'New',
|
||||
'type_id': self.requisition_type_id.id,
|
||||
'branch_id': self.branch_id.id,
|
||||
'state': 'draft',
|
||||
'company_id': self.purchase_indent_id.company_id.id,
|
||||
}
|
||||
@ -199,6 +204,7 @@ class WizRequisitionRequest(models.TransientModel):
|
||||
line_vals = {
|
||||
'product_id': current_line.product_id.id,
|
||||
'product_qty': current_line.product_qty,
|
||||
'branch_id': self.branch_id.id,
|
||||
'purchase_indent_ids':
|
||||
[(6, 0, current_line.purchase_indent_ids.ids)],
|
||||
'purchase_indent_line_id':
|
||||
@ -271,6 +277,7 @@ class WizRequisitionRequest(models.TransientModel):
|
||||
purchase_indent_ids = self.purchase_indent_id.search([
|
||||
('category_id', '=', self.purchase_indent_id.category_id.id),
|
||||
('state', 'in', ['confirm', 'requisition']),
|
||||
('branch_id', '=', self.purchase_indent_id.branch_id.id),
|
||||
('company_id', '=', self.purchase_indent_id.company_id.id)])
|
||||
for purchase_indent_id in purchase_indent_ids:
|
||||
check = False
|
||||
|
@ -18,6 +18,7 @@
|
||||
<field name="requisition_type_id"
|
||||
attrs="{'invisible': ['|', ('order_type', '!=', 'pa'), ('state', '=', 'confirm')], 'required': [('order_type', '=', 'pa')]}"
|
||||
widget="selection"/>
|
||||
<field name="branch_id" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('state', '!=', 'draft')]}">
|
||||
|
@ -121,12 +121,12 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Purchase Agreements">
|
||||
<header>
|
||||
<button name="%(action_purchase_requisition_to_so)d" type="action"
|
||||
string="New Quotation"
|
||||
attrs="{'invisible': [('state', '!=', 'open')]}"/>
|
||||
<!--<button name="%(action_purchase_requisition_to_so)d" type="action"-->
|
||||
<!--string="New Quotation"-->
|
||||
<!--attrs="{'invisible': [('state', '!=', 'open')]}"/>-->
|
||||
<button name="%(action_purchase_requisition_to_so)d" type="action"
|
||||
string="New Quotation" class="btn-primary"
|
||||
attrs="{'invisible': [('state', '!=', 'in_progress')]}"/>
|
||||
attrs="{'invisible': [('state', 'not in', ['in_progress', 'open'])]}"/>
|
||||
<button name="action_in_progress" states="draft" string="Confirm" type="object" class="btn-primary"/>
|
||||
<button name="action_open" states="in_progress" string="Validate" type="object" class="btn-primary"/>
|
||||
<button name="action_done" states="open" string="Done" type="object" class="btn-primary"/>
|
||||
|
@ -198,7 +198,7 @@
|
||||
<field name="code">NY</field>
|
||||
<field name="partner_id" ref="base.main_partner"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="branch_id" ref="base_branch_company.data_branch_1"/>
|
||||
<field name="branch_id" ref="base_branch_company.data_branch_4"/>
|
||||
</record>
|
||||
|
||||
<!-- WA -->
|
||||
|
Loading…
Reference in New Issue
Block a user