mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX] Travis
This commit is contained in:
committed by
Chanakya Soni
parent
e6a0cdcabc
commit
55c0b05234
@@ -2,21 +2,21 @@
|
|||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'RMA Purchase',
|
"name": "RMA Purchase",
|
||||||
'version': '12.0.1.0.0',
|
"version": "13.0.1.0.0",
|
||||||
'category': 'RMA',
|
"category": "RMA",
|
||||||
'summary': 'RMA from PO',
|
"summary": "RMA from PO",
|
||||||
'license': 'LGPL-3',
|
"license": "LGPL-3",
|
||||||
'author': 'Eficent, Odoo Community Association (OCA)',
|
"author": "Eficent, Odoo Community Association (OCA)",
|
||||||
'website': 'https://github.com/Eficent/stock-rma',
|
"website": "https://github.com/Eficent/stock-rma",
|
||||||
'depends': ['rma_account', 'purchase'],
|
"depends": ["rma_account", "purchase"],
|
||||||
'data': [
|
"data": [
|
||||||
'wizards/rma_order_line_make_purchase_order_view.xml',
|
"wizards/rma_order_line_make_purchase_order_view.xml",
|
||||||
'security/ir.model.access.csv',
|
"security/ir.model.access.csv",
|
||||||
'views/rma_operation_view.xml',
|
"views/rma_operation_view.xml",
|
||||||
'views/rma_order_view.xml',
|
"views/rma_order_view.xml",
|
||||||
'views/rma_order_line_view.xml',
|
"views/rma_order_line_view.xml",
|
||||||
'wizards/rma_add_purchase.xml',
|
"wizards/rma_add_purchase.xml",
|
||||||
],
|
],
|
||||||
'installable': True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,18 @@ class PurchaseOrder(models.Model):
|
|||||||
def new(self, vals):
|
def new(self, vals):
|
||||||
"""Allows to propose a line based on the RMA information."""
|
"""Allows to propose a line based on the RMA information."""
|
||||||
res = super(PurchaseOrder, self).new(vals)
|
res = super(PurchaseOrder, self).new(vals)
|
||||||
rma_line_id = self.env.context.get('rma_line_id')
|
rma_line_id = self.env.context.get("rma_line_id")
|
||||||
if rma_line_id:
|
if rma_line_id:
|
||||||
rma_line = self.env['rma.order.line'].browse(rma_line_id)
|
rma_line = self.env["rma.order.line"].browse(rma_line_id)
|
||||||
line = self.env['purchase.order.line'].new({
|
line = self.env["purchase.order.line"].new(
|
||||||
'product_id': rma_line.product_id.id,
|
{"product_id": rma_line.product_id.id}
|
||||||
})
|
)
|
||||||
line.onchange_product_id()
|
line.onchange_product_id()
|
||||||
line.update({
|
line.update(
|
||||||
'product_qty': rma_line.qty_to_purchase,
|
{
|
||||||
'product_uom': rma_line.uom_id.id,
|
"product_qty": rma_line.qty_to_purchase,
|
||||||
})
|
"product_uom": rma_line.uom_id.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
res.order_line = line
|
res.order_line = line
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -7,53 +7,71 @@ from odoo import api, fields, models
|
|||||||
class PurchaseOrderLine(models.Model):
|
class PurchaseOrderLine(models.Model):
|
||||||
_inherit = "purchase.order.line"
|
_inherit = "purchase.order.line"
|
||||||
|
|
||||||
rma_line_id = fields.Many2one(
|
rma_line_id = fields.Many2one(comodel_name="rma.order.line", string="RMA",)
|
||||||
comodel_name='rma.order.line', string='RMA',
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
def name_search(self, name="", args=None, operator="ilike", limit=100):
|
||||||
"""Allows to search by PO reference."""
|
"""Allows to search by PO reference."""
|
||||||
if not args:
|
if not args:
|
||||||
args = []
|
args = []
|
||||||
args += ['|',
|
args += [
|
||||||
|
"|",
|
||||||
(self._rec_name, operator, name),
|
(self._rec_name, operator, name),
|
||||||
('order_id.name', operator, name)]
|
("order_id.name", operator, name),
|
||||||
|
]
|
||||||
return super(PurchaseOrderLine, self).name_search(
|
return super(PurchaseOrderLine, self).name_search(
|
||||||
name=name, args=args, operator=operator, limit=limit)
|
name=name, args=args, operator=operator, limit=limit
|
||||||
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _name_search(self, name='', args=None, operator='ilike',
|
def _name_search(
|
||||||
limit=100, name_get_uid=None):
|
self, name="", args=None, operator="ilike", limit=100, name_get_uid=None
|
||||||
|
):
|
||||||
"""Typed text is cleared here for better extensibility."""
|
"""Typed text is cleared here for better extensibility."""
|
||||||
return super(PurchaseOrderLine, self)._name_search(
|
return super(PurchaseOrderLine, self)._name_search(
|
||||||
name='', args=args, operator=operator, limit=limit,
|
name="",
|
||||||
name_get_uid=name_get_uid)
|
args=args,
|
||||||
|
operator=operator,
|
||||||
|
limit=limit,
|
||||||
|
name_get_uid=name_get_uid,
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
res = []
|
res = []
|
||||||
if self.env.context.get('rma'):
|
if self.env.context.get("rma"):
|
||||||
for purchase in self:
|
for purchase in self:
|
||||||
invoices = self.env['account.invoice.line'].search(
|
invoices = self.env["account.invoice.line"].search(
|
||||||
[('purchase_line_id', '=', purchase.id)])
|
[("purchase_line_id", "=", purchase.id)]
|
||||||
|
)
|
||||||
if purchase.order_id.name:
|
if purchase.order_id.name:
|
||||||
res.append((purchase.id, "%s %s %s qty:%s" % (
|
|
||||||
purchase.order_id.name,
|
|
||||||
" ".join(str(x) for x in [
|
|
||||||
inv.number for inv in invoices.mapped(
|
|
||||||
'invoice_id')]),
|
|
||||||
purchase.product_id.name, purchase.product_qty)))
|
|
||||||
else:
|
|
||||||
res.append(
|
res.append(
|
||||||
super(PurchaseOrderLine, purchase).name_get()[0])
|
(
|
||||||
|
purchase.id,
|
||||||
|
"%s %s %s qty:%s"
|
||||||
|
% (
|
||||||
|
purchase.order_id.name,
|
||||||
|
" ".join(
|
||||||
|
str(x)
|
||||||
|
for x in [
|
||||||
|
inv.number
|
||||||
|
for inv in invoices.mapped("invoice_id")
|
||||||
|
]
|
||||||
|
),
|
||||||
|
purchase.product_id.name,
|
||||||
|
purchase.product_qty,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
res.append(super(PurchaseOrderLine, purchase).name_get()[0])
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return super(PurchaseOrderLine, self).name_get()
|
return super(PurchaseOrderLine, self).name_get()
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
rma_line_id = self.env.context.get('rma_line_id')
|
rma_line_id = self.env.context.get("rma_line_id")
|
||||||
if rma_line_id:
|
if rma_line_id:
|
||||||
vals['rma_line_id'] = rma_line_id
|
vals["rma_line_id"] = rma_line_id
|
||||||
return super(PurchaseOrderLine, self).create(vals)
|
return super(PurchaseOrderLine, self).create(vals)
|
||||||
|
|||||||
@@ -1,24 +1,27 @@
|
|||||||
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class RmaOperation(models.Model):
|
class RmaOperation(models.Model):
|
||||||
_inherit = 'rma.operation'
|
_inherit = "rma.operation"
|
||||||
|
|
||||||
purchase_policy = fields.Selection(
|
purchase_policy = fields.Selection(
|
||||||
selection=[('no', 'Not required'),
|
selection=[
|
||||||
('ordered', 'Based on Ordered Quantities'),
|
("no", "Not required"),
|
||||||
('delivered', 'Based on Delivered Quantities')],
|
("ordered", "Based on Ordered Quantities"),
|
||||||
string="Purchase Policy", default='no',
|
("delivered", "Based on Delivered Quantities"),
|
||||||
|
],
|
||||||
|
string="Purchase Policy",
|
||||||
|
default="no",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('purchase_policy')
|
@api.constrains("purchase_policy")
|
||||||
def _check_purchase_policy(self):
|
def _check_purchase_policy(self):
|
||||||
if self.filtered(
|
if self.filtered(lambda r: r.purchase_policy != "no" and r.type != "supplier"):
|
||||||
lambda r: r.purchase_policy != 'no' and r.type != 'supplier'):
|
raise ValidationError(
|
||||||
raise ValidationError(_(
|
_("Purchase Policy can only apply to supplier operations")
|
||||||
'Purchase Policy can only apply to supplier operations'))
|
)
|
||||||
|
|||||||
@@ -13,42 +13,41 @@ class RmaOrder(models.Model):
|
|||||||
po_count = 0
|
po_count = 0
|
||||||
rma_line_po = []
|
rma_line_po = []
|
||||||
for line in rec.rma_line_ids:
|
for line in rec.rma_line_ids:
|
||||||
rma_line_po += self.env['purchase.order'].search(
|
rma_line_po += (
|
||||||
[('origin', '=', line.name)]).ids
|
self.env["purchase.order"].search([("origin", "=", line.name)]).ids
|
||||||
|
)
|
||||||
if rma_line_po:
|
if rma_line_po:
|
||||||
po_count = len(list(set(rma_line_po)))
|
po_count = len(list(set(rma_line_po)))
|
||||||
rec.po_count = po_count
|
rec.po_count = po_count
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('rma_line_ids')
|
@api.depends("rma_line_ids")
|
||||||
def _compute_origin_po_count(self):
|
def _compute_origin_po_count(self):
|
||||||
for rma in self:
|
for rma in self:
|
||||||
purchases = rma.mapped(
|
purchases = rma.mapped("rma_line_ids.purchase_order_line_id.order_id")
|
||||||
'rma_line_ids.purchase_order_line_id.order_id')
|
|
||||||
rma.origin_po_count = len(purchases)
|
rma.origin_po_count = len(purchases)
|
||||||
|
|
||||||
po_count = fields.Integer(
|
po_count = fields.Integer(compute="_compute_po_count", string="# of PO")
|
||||||
compute='_compute_po_count', string='# of PO')
|
|
||||||
origin_po_count = fields.Integer(
|
origin_po_count = fields.Integer(
|
||||||
compute='_compute_origin_po_count', string='# of Origin PO')
|
compute="_compute_origin_po_count", string="# of Origin PO"
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_purchase_order(self):
|
def action_view_purchase_order(self):
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
action = self.env.ref("purchase.purchase_rfq")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
po_ids = self.env['purchase.order'].search(
|
po_ids = self.env["purchase.order"].search([("origin", "=", self.name)]).ids
|
||||||
[('origin', '=', self.name)]).ids
|
|
||||||
for line in self.rma_line_ids:
|
for line in self.rma_line_ids:
|
||||||
po_ids += self.env['purchase.order'].search(
|
po_ids += (
|
||||||
[('origin', '=', line.name)]).ids
|
self.env["purchase.order"].search([("origin", "=", line.name)]).ids
|
||||||
result['domain'] = [('id', 'in', po_ids)]
|
)
|
||||||
|
result["domain"] = [("id", "in", po_ids)]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_origin_purchase_order(self):
|
def action_view_origin_purchase_order(self):
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
action = self.env.ref("purchase.purchase_rfq")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
po_ids = self.mapped(
|
po_ids = self.mapped("rma_line_ids.purchase_order_line_id.order_id").ids
|
||||||
'rma_line_ids.purchase_order_line_id.order_id').ids
|
result["domain"] = [("id", "in", po_ids)]
|
||||||
result['domain'] = [('id', 'in', po_ids)]
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
from odoo.addons import decimal_precision as dp
|
from odoo.addons import decimal_precision as dp
|
||||||
|
|
||||||
|
|
||||||
@@ -12,16 +13,18 @@ class RmaOrderLine(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _compute_purchase_count(self):
|
def _compute_purchase_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
purchase_line_count = self.env['purchase.order.line'].search(
|
purchase_line_count = self.env["purchase.order.line"].search(
|
||||||
[('rma_line_id', '=', rec.id)])
|
[("rma_line_id", "=", rec.id)]
|
||||||
rec.purchase_count = len(purchase_line_count.mapped('order_id'))
|
)
|
||||||
|
rec.purchase_count = len(purchase_line_count.mapped("order_id"))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_purchase_order_lines(self):
|
def _compute_purchase_order_lines(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
purchase_list = []
|
purchase_list = []
|
||||||
for line in self.env['purchase.order.line'].search(
|
for line in self.env["purchase.order.line"].search(
|
||||||
[('rma_line_id', '=', rec.id)]):
|
[("rma_line_id", "=", rec.id)]
|
||||||
|
):
|
||||||
purchase_list.append(line.id)
|
purchase_list.append(line.id)
|
||||||
rec.purchase_order_line_ids = [(6, 0, purchase_list)]
|
rec.purchase_order_line_ids = [(6, 0, purchase_list)]
|
||||||
|
|
||||||
@@ -29,76 +32,90 @@ class RmaOrderLine(models.Model):
|
|||||||
def _compute_qty_purchase(self):
|
def _compute_qty_purchase(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.qty_purchased = rec._get_rma_purchased_qty()
|
rec.qty_purchased = rec._get_rma_purchased_qty()
|
||||||
if rec.purchase_policy == 'ordered':
|
if rec.purchase_policy == "ordered":
|
||||||
rec.qty_to_purchase = rec.product_qty - rec.qty_purchased
|
rec.qty_to_purchase = rec.product_qty - rec.qty_purchased
|
||||||
elif rec.purchase_policy == 'delivered':
|
elif rec.purchase_policy == "delivered":
|
||||||
rec.qty_to_purchase = rec.qty_delivered - rec.qty_purchased
|
rec.qty_to_purchase = rec.qty_delivered - rec.qty_purchased
|
||||||
else:
|
else:
|
||||||
rec.qty_to_purchase = 0.0
|
rec.qty_to_purchase = 0.0
|
||||||
|
|
||||||
purchase_count = fields.Integer(
|
purchase_count = fields.Integer(
|
||||||
compute='_compute_purchase_count', string='# of Purchases',
|
compute="_compute_purchase_count", string="# of Purchases",
|
||||||
)
|
)
|
||||||
purchase_order_line_id = fields.Many2one(
|
purchase_order_line_id = fields.Many2one(
|
||||||
comodel_name='purchase.order.line', string='Originating Purchase Line',
|
comodel_name="purchase.order.line",
|
||||||
ondelete='restrict',
|
string="Originating Purchase Line",
|
||||||
readonly=True, states={'draft': [('readonly', False)]},
|
ondelete="restrict",
|
||||||
|
readonly=True,
|
||||||
|
states={"draft": [("readonly", False)]},
|
||||||
)
|
)
|
||||||
purchase_id = fields.Many2one(
|
purchase_id = fields.Many2one(
|
||||||
string="Source Purchase Order",
|
string="Source Purchase Order",
|
||||||
related='purchase_order_line_id.order_id',
|
related="purchase_order_line_id.order_id",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
purchase_order_line_ids = fields.Many2many(
|
purchase_order_line_ids = fields.Many2many(
|
||||||
comodel_name='purchase.order.line',
|
comodel_name="purchase.order.line",
|
||||||
relation='purchase_line_rma_line_rel',
|
relation="purchase_line_rma_line_rel",
|
||||||
column1='rma_order_line_id', column2='purchase_order_line_id',
|
column1="rma_order_line_id",
|
||||||
string='Purchase Order Lines', compute='_compute_purchase_order_lines',
|
column2="purchase_order_line_id",
|
||||||
|
string="Purchase Order Lines",
|
||||||
|
compute="_compute_purchase_order_lines",
|
||||||
)
|
)
|
||||||
purchase_policy = fields.Selection(
|
purchase_policy = fields.Selection(
|
||||||
selection=[('no', 'Not required'),
|
selection=[
|
||||||
('ordered', 'Based on Ordered Quantities'),
|
("no", "Not required"),
|
||||||
('delivered', 'Based on Delivered Quantities')],
|
("ordered", "Based on Ordered Quantities"),
|
||||||
string="Purchase Policy", default='no',
|
("delivered", "Based on Delivered Quantities"),
|
||||||
|
],
|
||||||
|
string="Purchase Policy",
|
||||||
|
default="no",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
manual_purchase_line_ids = fields.One2many(
|
manual_purchase_line_ids = fields.One2many(
|
||||||
comodel_name='purchase.order.line',
|
comodel_name="purchase.order.line",
|
||||||
inverse_name='rma_line_id',
|
inverse_name="rma_line_id",
|
||||||
string='Manual Purchase Order Lines',
|
string="Manual Purchase Order Lines",
|
||||||
readonly=True, copy=False)
|
readonly=True,
|
||||||
|
copy=False,
|
||||||
|
)
|
||||||
qty_to_purchase = fields.Float(
|
qty_to_purchase = fields.Float(
|
||||||
string='Qty To Purchase', copy=False,
|
string="Qty To Purchase",
|
||||||
digits=dp.get_precision('Product Unit of Measure'),
|
copy=False,
|
||||||
readonly=True, compute='_compute_qty_purchase'
|
digits=dp.get_precision("Product Unit of Measure"),
|
||||||
|
readonly=True,
|
||||||
|
compute="_compute_qty_purchase",
|
||||||
)
|
)
|
||||||
qty_purchased = fields.Float(
|
qty_purchased = fields.Float(
|
||||||
string='Qty Purchased', copy=False,
|
string="Qty Purchased",
|
||||||
digits=dp.get_precision('Product Unit of Measure'),
|
copy=False,
|
||||||
readonly=True, compute='_compute_qty_purchase'
|
digits=dp.get_precision("Product Unit of Measure"),
|
||||||
|
readonly=True,
|
||||||
|
compute="_compute_qty_purchase",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.onchange('product_id', 'partner_id')
|
@api.onchange("product_id", "partner_id")
|
||||||
def _onchange_product_id(self):
|
def _onchange_product_id(self):
|
||||||
"""Domain for purchase_order_line_id is computed here to make
|
"""Domain for purchase_order_line_id is computed here to make
|
||||||
it dynamic."""
|
it dynamic."""
|
||||||
res = super(RmaOrderLine, self)._onchange_product_id()
|
res = super(RmaOrderLine, self)._onchange_product_id()
|
||||||
if not res.get('domain'):
|
if not res.get("domain"):
|
||||||
res['domain'] = {}
|
res["domain"] = {}
|
||||||
domain = [
|
domain = [
|
||||||
'|',
|
"|",
|
||||||
('order_id.partner_id', '=', self.partner_id.id),
|
("order_id.partner_id", "=", self.partner_id.id),
|
||||||
('order_id.partner_id', 'child_of', self.partner_id.id)]
|
("order_id.partner_id", "child_of", self.partner_id.id),
|
||||||
|
]
|
||||||
if self.product_id:
|
if self.product_id:
|
||||||
domain.append(('product_id', '=', self.product_id.id))
|
domain.append(("product_id", "=", self.product_id.id))
|
||||||
res['domain']['purchase_order_line_id'] = domain
|
res["domain"]["purchase_order_line_id"] = domain
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('operation_id')
|
@api.onchange("operation_id")
|
||||||
def _onchange_operation_id(self):
|
def _onchange_operation_id(self):
|
||||||
res = super(RmaOrderLine, self)._onchange_operation_id()
|
res = super(RmaOrderLine, self)._onchange_operation_id()
|
||||||
if self.operation_id:
|
if self.operation_id:
|
||||||
self.purchase_policy = self.operation_id.purchase_policy or 'no'
|
self.purchase_policy = self.operation_id.purchase_policy or "no"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -106,98 +123,115 @@ class RmaOrderLine(models.Model):
|
|||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if not self.type:
|
if not self.type:
|
||||||
self.type = self._get_default_type()
|
self.type = self._get_default_type()
|
||||||
if self.type == 'customer':
|
if self.type == "customer":
|
||||||
operation = line.product_id.rma_customer_operation_id or \
|
operation = (
|
||||||
line.product_id.categ_id.rma_customer_operation_id
|
line.product_id.rma_customer_operation_id
|
||||||
|
or line.product_id.categ_id.rma_customer_operation_id
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
operation = line.product_id.rma_supplier_operation_id or \
|
operation = (
|
||||||
line.product_id.categ_id.rma_supplier_operation_id
|
line.product_id.rma_supplier_operation_id
|
||||||
|
or line.product_id.categ_id.rma_supplier_operation_id
|
||||||
|
)
|
||||||
if not operation:
|
if not operation:
|
||||||
operation = self.env['rma.operation'].search(
|
operation = self.env["rma.operation"].search(
|
||||||
[('type', '=', self.type)], limit=1)
|
[("type", "=", self.type)], limit=1
|
||||||
|
)
|
||||||
if not operation:
|
if not operation:
|
||||||
raise ValidationError(_("Please define an operation first"))
|
raise ValidationError(_("Please define an operation first"))
|
||||||
|
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env['stock.location.route'].search(
|
route = self.env["stock.location.route"].search(
|
||||||
[('rma_selectable', '=', True)], limit=1)
|
[("rma_selectable", "=", True)], limit=1
|
||||||
|
)
|
||||||
if not route:
|
if not route:
|
||||||
raise ValidationError(_("Please define a rma route."))
|
raise ValidationError(_("Please define a rma route."))
|
||||||
|
|
||||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
warehouse = self.env['stock.warehouse'].search(
|
warehouse = self.env["stock.warehouse"].search(
|
||||||
[('company_id', '=', self.company_id.id),
|
[("company_id", "=", self.company_id.id), ("lot_rma_id", "!=", False)],
|
||||||
('lot_rma_id', '!=', False)], limit=1)
|
limit=1,
|
||||||
|
)
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError(_(
|
raise ValidationError(
|
||||||
"Please define a warehouse with a default rma location."))
|
_("Please define a warehouse with a default rma location.")
|
||||||
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'product_id': line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
'origin': line.order_id.name,
|
"origin": line.order_id.name,
|
||||||
'uom_id': line.product_uom.id,
|
"uom_id": line.product_uom.id,
|
||||||
'operation_id': operation.id,
|
"operation_id": operation.id,
|
||||||
'product_qty': line.product_qty,
|
"product_qty": line.product_qty,
|
||||||
'price_unit': line.currency_id._convert(
|
"price_unit": line.currency_id._convert(
|
||||||
line.price_unit, line.currency_id,
|
line.price_unit,
|
||||||
self.env.user.company_id, fields.Date.today(), round=False),
|
line.currency_id,
|
||||||
'in_route_id': operation.in_route_id.id or route,
|
self.env.user.company_id,
|
||||||
'out_route_id': operation.out_route_id.id or route,
|
fields.Date.today(),
|
||||||
'receipt_policy': operation.receipt_policy,
|
round=False,
|
||||||
'currency_id': line.currency_id.id,
|
),
|
||||||
'location_id': (operation.location_id.id or
|
"in_route_id": operation.in_route_id.id or route,
|
||||||
operation.in_warehouse_id.lot_rma_id.id or
|
"out_route_id": operation.out_route_id.id or route,
|
||||||
warehouse.lot_rma_id.id),
|
"receipt_policy": operation.receipt_policy,
|
||||||
'refund_policy': operation.refund_policy,
|
"currency_id": line.currency_id.id,
|
||||||
'delivery_policy': operation.delivery_policy,
|
"location_id": (
|
||||||
'in_warehouse_id': operation.in_warehouse_id.id or warehouse.id,
|
operation.location_id.id
|
||||||
'out_warehouse_id': operation.out_warehouse_id.id or warehouse.id,
|
or operation.in_warehouse_id.lot_rma_id.id
|
||||||
|
or warehouse.lot_rma_id.id
|
||||||
|
),
|
||||||
|
"refund_policy": operation.refund_policy,
|
||||||
|
"delivery_policy": operation.delivery_policy,
|
||||||
|
"in_warehouse_id": operation.in_warehouse_id.id or warehouse.id,
|
||||||
|
"out_warehouse_id": operation.out_warehouse_id.id or warehouse.id,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.onchange('purchase_order_line_id')
|
@api.onchange("purchase_order_line_id")
|
||||||
def _onchange_purchase_order_line_id(self):
|
def _onchange_purchase_order_line_id(self):
|
||||||
if not self.purchase_order_line_id:
|
if not self.purchase_order_line_id:
|
||||||
return
|
return
|
||||||
data = self._prepare_rma_line_from_po_line(
|
data = self._prepare_rma_line_from_po_line(self.purchase_order_line_id)
|
||||||
self.purchase_order_line_id)
|
|
||||||
self.update(data)
|
self.update(data)
|
||||||
self._remove_other_data_origin('purchase_order_line_id')
|
self._remove_other_data_origin("purchase_order_line_id")
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('purchase_order_line_id', 'partner_id')
|
@api.constrains("purchase_order_line_id", "partner_id")
|
||||||
def _check_purchase_partner(self):
|
def _check_purchase_partner(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if (rec.purchase_order_line_id and
|
if (
|
||||||
rec.purchase_order_line_id.order_id.partner_id !=
|
rec.purchase_order_line_id
|
||||||
rec.partner_id):
|
and rec.purchase_order_line_id.order_id.partner_id != rec.partner_id
|
||||||
raise ValidationError(_(
|
):
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
"RMA customer and originating purchase line customer "
|
"RMA customer and originating purchase line customer "
|
||||||
"doesn't match."))
|
"doesn't match."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _remove_other_data_origin(self, exception):
|
def _remove_other_data_origin(self, exception):
|
||||||
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
||||||
if not exception == 'purchase_order_line_id':
|
if not exception == "purchase_order_line_id":
|
||||||
self.purchase_order_line_id = False
|
self.purchase_order_line_id = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_purchase_order(self):
|
def action_view_purchase_order(self):
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
action = self.env.ref("purchase.purchase_rfq")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
orders = self.mapped('purchase_order_line_ids.order_id')
|
orders = self.mapped("purchase_order_line_ids.order_id")
|
||||||
result['domain'] = [('id', 'in', orders.ids)]
|
result["domain"] = [("id", "in", orders.ids)]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_rma_purchased_qty(self):
|
def _get_rma_purchased_qty(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
qty = 0.0
|
qty = 0.0
|
||||||
if self.type == 'customer':
|
if self.type == "customer":
|
||||||
return qty
|
return qty
|
||||||
for line in self.purchase_order_line_ids.filtered(
|
for line in self.purchase_order_line_ids.filtered(
|
||||||
lambda p: p.state not in ('draft', 'sent', 'cancel')):
|
lambda p: p.state not in ("draft", "sent", "cancel")
|
||||||
qty += self.uom_id._compute_quantity(
|
):
|
||||||
line.product_qty, line.product_uom)
|
qty += self.uom_id._compute_quantity(line.product_qty, line.product_uom)
|
||||||
return qty
|
return qty
|
||||||
|
|||||||
0
rma_purchase/security/ir.model.access.csv
Executable file → Normal file
0
rma_purchase/security/ir.model.access.csv
Executable file → Normal file
@@ -1,92 +1,96 @@
|
|||||||
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo.tests import common
|
|
||||||
from odoo.fields import Datetime
|
from odoo.fields import Datetime
|
||||||
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
class TestRmaPurchase(common.TransactionCase):
|
class TestRmaPurchase(common.TransactionCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRmaPurchase, self).setUp()
|
super(TestRmaPurchase, self).setUp()
|
||||||
|
|
||||||
self.rma_obj = self.env['rma.order']
|
self.rma_obj = self.env["rma.order"]
|
||||||
self.rma_line_obj = self.env['rma.order.line']
|
self.rma_line_obj = self.env["rma.order.line"]
|
||||||
self.rma_op_obj = self.env['rma.operation']
|
self.rma_op_obj = self.env["rma.operation"]
|
||||||
self.rma_add_purchase_wiz = self.env['rma_add_purchase']
|
self.rma_add_purchase_wiz = self.env["rma_add_purchase"]
|
||||||
self.po_obj = self.env['purchase.order']
|
self.po_obj = self.env["purchase.order"]
|
||||||
self.pol_obj = self.env['purchase.order.line']
|
self.pol_obj = self.env["purchase.order.line"]
|
||||||
self.product_obj = self.env['product.product']
|
self.product_obj = self.env["product.product"]
|
||||||
self.partner_obj = self.env['res.partner']
|
self.partner_obj = self.env["res.partner"]
|
||||||
|
|
||||||
self.rma_route_cust = self.env.ref('rma.route_rma_customer')
|
self.rma_route_cust = self.env.ref("rma.route_rma_customer")
|
||||||
|
|
||||||
# Create supplier
|
# Create supplier
|
||||||
supplier1 = self.partner_obj.create({'name': 'Supplier 1'})
|
supplier1 = self.partner_obj.create({"name": "Supplier 1"})
|
||||||
|
|
||||||
# Create products
|
# Create products
|
||||||
self.product_1 = self.product_obj.create({
|
self.product_1 = self.product_obj.create(
|
||||||
'name': 'Test Product 1',
|
{"name": "Test Product 1", "type": "product"}
|
||||||
'type': 'product',
|
)
|
||||||
})
|
self.product_2 = self.product_obj.create(
|
||||||
self.product_2 = self.product_obj.create({
|
{"name": "Test Product 2", "type": "product"}
|
||||||
'name': 'Test Product 2',
|
)
|
||||||
'type': 'product',
|
|
||||||
})
|
|
||||||
|
|
||||||
# Create PO:
|
# Create PO:
|
||||||
self.po = self.po_obj.create({
|
self.po = self.po_obj.create({"partner_id": supplier1.id})
|
||||||
'partner_id': supplier1.id,
|
self.pol_1 = self.pol_obj.create(
|
||||||
})
|
{
|
||||||
self.pol_1 = self.pol_obj.create({
|
"name": self.product_1.name,
|
||||||
'name': self.product_1.name,
|
"order_id": self.po.id,
|
||||||
'order_id': self.po.id,
|
"product_id": self.product_1.id,
|
||||||
'product_id': self.product_1.id,
|
"product_qty": 20.0,
|
||||||
'product_qty': 20.0,
|
"product_uom": self.product_1.uom_id.id,
|
||||||
'product_uom': self.product_1.uom_id.id,
|
"price_unit": 100.0,
|
||||||
'price_unit': 100.0,
|
"date_planned": Datetime.now(),
|
||||||
'date_planned': Datetime.now(),
|
}
|
||||||
})
|
)
|
||||||
self.pol_2 = self.pol_obj.create({
|
self.pol_2 = self.pol_obj.create(
|
||||||
'name': self.product_2.name,
|
{
|
||||||
'order_id': self.po.id,
|
"name": self.product_2.name,
|
||||||
'product_id': self.product_2.id,
|
"order_id": self.po.id,
|
||||||
'product_qty': 18.0,
|
"product_id": self.product_2.id,
|
||||||
'product_uom': self.product_2.uom_id.id,
|
"product_qty": 18.0,
|
||||||
'price_unit': 150.0,
|
"product_uom": self.product_2.uom_id.id,
|
||||||
'date_planned': Datetime.now(),
|
"price_unit": 150.0,
|
||||||
})
|
"date_planned": Datetime.now(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# Create RMA group:
|
# Create RMA group:
|
||||||
self.rma_group = self.rma_obj.create({
|
self.rma_group = self.rma_obj.create(
|
||||||
'partner_id': supplier1.id,
|
{"partner_id": supplier1.id, "type": "supplier"}
|
||||||
'type': 'supplier',
|
)
|
||||||
})
|
|
||||||
|
|
||||||
def test_01_add_from_purchase_order(self):
|
def test_01_add_from_purchase_order(self):
|
||||||
"""Test wizard to create supplier RMA from Purchase Orders."""
|
"""Test wizard to create supplier RMA from Purchase Orders."""
|
||||||
self.assertEqual(self.rma_group.origin_po_count, 0)
|
self.assertEqual(self.rma_group.origin_po_count, 0)
|
||||||
add_purchase = self.rma_add_purchase_wiz.with_context({
|
add_purchase = self.rma_add_purchase_wiz.with_context(
|
||||||
'supplier': True,
|
{
|
||||||
'active_ids': self.rma_group.id,
|
"supplier": True,
|
||||||
'active_model': 'rma.order',
|
"active_ids": self.rma_group.id,
|
||||||
}).create({
|
"active_model": "rma.order",
|
||||||
'purchase_id': self.po.id,
|
}
|
||||||
'purchase_line_ids': [(6, 0, self.po.order_line.ids)],
|
).create(
|
||||||
})
|
{
|
||||||
|
"purchase_id": self.po.id,
|
||||||
|
"purchase_line_ids": [(6, 0, self.po.order_line.ids)],
|
||||||
|
}
|
||||||
|
)
|
||||||
add_purchase.add_lines()
|
add_purchase.add_lines()
|
||||||
self.assertEqual(len(self.rma_group.rma_line_ids), 2)
|
self.assertEqual(len(self.rma_group.rma_line_ids), 2)
|
||||||
for t in self.rma_group.rma_line_ids.mapped('type'):
|
for t in self.rma_group.rma_line_ids.mapped("type"):
|
||||||
self.assertEqual(t, 'supplier')
|
self.assertEqual(t, "supplier")
|
||||||
self.assertEqual(self.rma_group.origin_po_count, 1)
|
self.assertEqual(self.rma_group.origin_po_count, 1)
|
||||||
|
|
||||||
def test_02_fill_rma_from_po_line(self):
|
def test_02_fill_rma_from_po_line(self):
|
||||||
"""Test filling a RMA (line) from a Purchase Order line."""
|
"""Test filling a RMA (line) from a Purchase Order line."""
|
||||||
rma = self.rma_line_obj.new({
|
rma = self.rma_line_obj.new(
|
||||||
'partner_id': self.po.partner_id.id,
|
{
|
||||||
'purchase_order_line_id': self.pol_1.id,
|
"partner_id": self.po.partner_id.id,
|
||||||
'type': 'supplier',
|
"purchase_order_line_id": self.pol_1.id,
|
||||||
})
|
"type": "supplier",
|
||||||
|
}
|
||||||
|
)
|
||||||
self.assertFalse(rma.product_id)
|
self.assertFalse(rma.product_id)
|
||||||
rma._onchange_purchase_order_line_id()
|
rma._onchange_purchase_order_line_id()
|
||||||
self.assertEqual(rma.product_id, self.product_1)
|
self.assertEqual(rma.product_id, self.product_1)
|
||||||
|
|||||||
@@ -15,10 +15,14 @@
|
|||||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_button_form" />
|
<field name="inherit_id" ref="rma.view_rma_line_supplier_button_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<header position="inside">
|
<header position="inside">
|
||||||
<button name="%(action_rma_order_line_make_purchase_order)d" states="approved"
|
<button
|
||||||
string="Create Purchase Order" class="oe_highlight"
|
name="%(action_rma_order_line_make_purchase_order)d"
|
||||||
|
states="approved"
|
||||||
|
string="Create Purchase Order"
|
||||||
|
class="oe_highlight"
|
||||||
context="{'rma_line_id': active_id, 'default_partner_id': partner_id}"
|
context="{'rma_line_id': active_id, 'default_partner_id': partner_id}"
|
||||||
type="action"/>
|
type="action"
|
||||||
|
/>
|
||||||
</header>
|
</header>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -29,21 +33,29 @@
|
|||||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_form" />
|
<field name="inherit_id" ref="rma.view_rma_line_supplier_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<div name='button_box' position="inside">
|
<div name='button_box' position="inside">
|
||||||
<button type="object" name="action_view_purchase_order"
|
<button
|
||||||
|
type="object"
|
||||||
|
name="action_view_purchase_order"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-shopping-cart"
|
icon="fa-shopping-cart"
|
||||||
groups="purchase.group_purchase_user">
|
groups="purchase.group_purchase_user"
|
||||||
<field name="purchase_count" widget="statinfo"
|
>
|
||||||
string="Purchase Orders"/>
|
<field
|
||||||
|
name="purchase_count"
|
||||||
|
widget="statinfo"
|
||||||
|
string="Purchase Orders"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<group name="main_info" position="inside">
|
<group name="main_info" position="inside">
|
||||||
<field name="purchase_order_line_id"
|
<field
|
||||||
|
name="purchase_order_line_id"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
context="{'rma': True}"
|
context="{'rma': True}"
|
||||||
domain="['|',
|
domain="['|',
|
||||||
('order_id.partner_id', '=', partner_id),
|
('order_id.partner_id', '=', partner_id),
|
||||||
('order_id.partner_id', 'child_of', partner_id)]"/>
|
('order_id.partner_id', 'child_of', partner_id)]"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group name="quantities" position="inside">
|
<group name="quantities" position="inside">
|
||||||
<group>
|
<group>
|
||||||
@@ -55,8 +67,10 @@
|
|||||||
<field name="purchase_policy" />
|
<field name="purchase_policy" />
|
||||||
</field>
|
</field>
|
||||||
<field name="origin" position="after">
|
<field name="origin" position="after">
|
||||||
<field name="purchase_id"
|
<field
|
||||||
attrs="{'invisible': [('purchase_order_line_id', '=', False)]}"/>
|
name="purchase_id"
|
||||||
|
attrs="{'invisible': [('purchase_order_line_id', '=', False)]}"
|
||||||
|
/>
|
||||||
</field>
|
</field>
|
||||||
<notebook position="inside">
|
<notebook position="inside">
|
||||||
<page name="purchase" string="Purchase Lines">
|
<page name="purchase" string="Purchase Lines">
|
||||||
|
|||||||
@@ -7,20 +7,31 @@
|
|||||||
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
|
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<div name='button_box' position="inside">
|
<div name='button_box' position="inside">
|
||||||
<button type="object" name="action_view_purchase_order"
|
<button
|
||||||
|
type="object"
|
||||||
|
name="action_view_purchase_order"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-shopping-cart"
|
icon="fa-shopping-cart"
|
||||||
groups="purchase.group_purchase_user">
|
groups="purchase.group_purchase_user"
|
||||||
<field name="po_count" widget="statinfo"
|
>
|
||||||
string="Purchase Orders"/>
|
<field
|
||||||
|
name="po_count"
|
||||||
|
widget="statinfo"
|
||||||
|
string="Purchase Orders"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button type="object"
|
<button
|
||||||
|
type="object"
|
||||||
name="action_view_origin_purchase_order"
|
name="action_view_origin_purchase_order"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-shopping-cart"
|
icon="fa-shopping-cart"
|
||||||
groups="purchase.group_purchase_user">
|
groups="purchase.group_purchase_user"
|
||||||
<field name="origin_po_count" widget="statinfo"
|
>
|
||||||
string="Origin PO"/>
|
<field
|
||||||
|
name="origin_po_count"
|
||||||
|
widget="statinfo"
|
||||||
|
string="Origin PO"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -6,91 +6,112 @@ from odoo.exceptions import ValidationError
|
|||||||
|
|
||||||
|
|
||||||
class RmaAddPurchase(models.TransientModel):
|
class RmaAddPurchase(models.TransientModel):
|
||||||
_name = 'rma_add_purchase'
|
_name = "rma_add_purchase"
|
||||||
_description = 'Wizard to add rma lines'
|
_description = "Wizard to add rma lines"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields_list):
|
def default_get(self, fields_list):
|
||||||
res = super(RmaAddPurchase, self).default_get(fields_list)
|
res = super(RmaAddPurchase, self).default_get(fields_list)
|
||||||
rma_obj = self.env['rma.order']
|
rma_obj = self.env["rma.order"]
|
||||||
rma_id = self.env.context['active_ids'] or []
|
rma_id = self.env.context["active_ids"] or []
|
||||||
active_model = self.env.context['active_model']
|
active_model = self.env.context["active_model"]
|
||||||
if not rma_id:
|
if not rma_id:
|
||||||
return res
|
return res
|
||||||
assert active_model == 'rma.order', 'Bad context propagation'
|
assert active_model == "rma.order", "Bad context propagation"
|
||||||
|
|
||||||
rma = rma_obj.browse(rma_id)
|
rma = rma_obj.browse(rma_id)
|
||||||
res['rma_id'] = rma.id
|
res["rma_id"] = rma.id
|
||||||
res['partner_id'] = rma.partner_id.id
|
res["partner_id"] = rma.partner_id.id
|
||||||
res['purchase_id'] = False
|
res["purchase_id"] = False
|
||||||
res['purchase_line_ids'] = False
|
res["purchase_line_ids"] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
rma_id = fields.Many2one(
|
rma_id = fields.Many2one(
|
||||||
comodel_name='rma.order', string='RMA Order', readonly=True)
|
comodel_name="rma.order", string="RMA Order", readonly=True
|
||||||
|
)
|
||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
comodel_name='res.partner', string='Partner', readonly=True)
|
comodel_name="res.partner", string="Partner", readonly=True
|
||||||
purchase_id = fields.Many2one(
|
)
|
||||||
comodel_name='purchase.order', string='Order')
|
purchase_id = fields.Many2one(comodel_name="purchase.order", string="Order")
|
||||||
purchase_line_ids = fields.Many2many(
|
purchase_line_ids = fields.Many2many(
|
||||||
comodel_name='purchase.order.line',
|
comodel_name="purchase.order.line",
|
||||||
relation='rma_add_purchase_add_line_rel',
|
relation="rma_add_purchase_add_line_rel",
|
||||||
column1='rma_add_purchase_id', column2='purchase_line_id',
|
column1="rma_add_purchase_id",
|
||||||
readonly=False, string='Purchase Order Lines')
|
column2="purchase_line_id",
|
||||||
|
readonly=False,
|
||||||
|
string="Purchase Order Lines",
|
||||||
|
)
|
||||||
|
|
||||||
def _prepare_rma_line_from_po_line(self, line):
|
def _prepare_rma_line_from_po_line(self, line):
|
||||||
if self.env.context.get('customer'):
|
if self.env.context.get("customer"):
|
||||||
operation = line.product_id.rma_customer_operation_id or \
|
operation = (
|
||||||
line.product_id.categ_id.rma_customer_operation_id
|
line.product_id.rma_customer_operation_id
|
||||||
|
or line.product_id.categ_id.rma_customer_operation_id
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
operation = line.product_id.rma_supplier_operation_id or \
|
operation = (
|
||||||
line.product_id.categ_id.rma_supplier_operation_id
|
line.product_id.rma_supplier_operation_id
|
||||||
|
or line.product_id.categ_id.rma_supplier_operation_id
|
||||||
|
)
|
||||||
if not operation:
|
if not operation:
|
||||||
operation = self.env['rma.operation'].search(
|
operation = self.env["rma.operation"].search(
|
||||||
[('type', '=', self.rma_id.type)], limit=1)
|
[("type", "=", self.rma_id.type)], limit=1
|
||||||
|
)
|
||||||
if not operation:
|
if not operation:
|
||||||
raise ValidationError(_("Please define an operation first"))
|
raise ValidationError(_("Please define an operation first"))
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env['stock.location.route'].search(
|
route = self.env["stock.location.route"].search(
|
||||||
[('rma_selectable', '=', True)], limit=1)
|
[("rma_selectable", "=", True)], limit=1
|
||||||
|
)
|
||||||
if not route:
|
if not route:
|
||||||
raise ValidationError(_("Please define a rma route."))
|
raise ValidationError(_("Please define a rma route."))
|
||||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
warehouse = self.env['stock.warehouse'].search(
|
warehouse = self.env["stock.warehouse"].search(
|
||||||
[('company_id', '=', self.rma_id.company_id.id),
|
[
|
||||||
('lot_rma_id', '!=', False)], limit=1)
|
("company_id", "=", self.rma_id.company_id.id),
|
||||||
|
("lot_rma_id", "!=", False),
|
||||||
|
],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError(_("Please define a warehouse with a "
|
raise ValidationError(
|
||||||
"default rma location."))
|
_("Please define a warehouse with a " "default rma location.")
|
||||||
|
)
|
||||||
data = {
|
data = {
|
||||||
'partner_id': self.partner_id.id,
|
"partner_id": self.partner_id.id,
|
||||||
'purchase_order_line_id': line.id,
|
"purchase_order_line_id": line.id,
|
||||||
'product_id': line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
'origin': line.order_id.name,
|
"origin": line.order_id.name,
|
||||||
'uom_id': line.product_uom.id,
|
"uom_id": line.product_uom.id,
|
||||||
'operation_id': operation.id,
|
"operation_id": operation.id,
|
||||||
'product_qty': line.product_qty,
|
"product_qty": line.product_qty,
|
||||||
'price_unit': line.currency_id._convert(
|
"price_unit": line.currency_id._convert(
|
||||||
line.price_unit, line.currency_id,
|
line.price_unit,
|
||||||
self.env.user.company_id, fields.Date.today(), round=False),
|
line.currency_id,
|
||||||
'rma_id': self.rma_id.id,
|
self.env.user.company_id,
|
||||||
'in_route_id': operation.in_route_id.id or route,
|
fields.Date.today(),
|
||||||
'out_route_id': operation.out_route_id.id or route,
|
round=False,
|
||||||
'receipt_policy': operation.receipt_policy,
|
),
|
||||||
'location_id': (operation.location_id.id or
|
"rma_id": self.rma_id.id,
|
||||||
operation.in_warehouse_id.lot_rma_id.id or
|
"in_route_id": operation.in_route_id.id or route,
|
||||||
warehouse.lot_rma_id.id),
|
"out_route_id": operation.out_route_id.id or route,
|
||||||
'refund_policy': operation.refund_policy,
|
"receipt_policy": operation.receipt_policy,
|
||||||
'delivery_policy': operation.delivery_policy,
|
"location_id": (
|
||||||
'in_warehouse_id': operation.in_warehouse_id.id or warehouse.id,
|
operation.location_id.id
|
||||||
'out_warehouse_id': operation.out_warehouse_id.id or warehouse.id,
|
or operation.in_warehouse_id.lot_rma_id.id
|
||||||
|
or warehouse.lot_rma_id.id
|
||||||
|
),
|
||||||
|
"refund_policy": operation.refund_policy,
|
||||||
|
"delivery_policy": operation.delivery_policy,
|
||||||
|
"in_warehouse_id": operation.in_warehouse_id.id or warehouse.id,
|
||||||
|
"out_warehouse_id": operation.out_warehouse_id.id or warehouse.id,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_rma_data(self):
|
def _get_rma_data(self):
|
||||||
data = {
|
data = {
|
||||||
'date_rma': fields.Datetime.now(),
|
"date_rma": fields.Datetime.now(),
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -103,7 +124,7 @@ class RmaAddPurchase(models.TransientModel):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def add_lines(self):
|
def add_lines(self):
|
||||||
rma_line_obj = self.env['rma.order.line']
|
rma_line_obj = self.env["rma.order.line"]
|
||||||
existing_purchase_lines = self._get_existing_purchase_lines()
|
existing_purchase_lines = self._get_existing_purchase_lines()
|
||||||
for line in self.purchase_line_ids:
|
for line in self.purchase_line_ids:
|
||||||
# Load a PO line only once
|
# Load a PO line only once
|
||||||
@@ -113,4 +134,4 @@ class RmaAddPurchase(models.TransientModel):
|
|||||||
rma = self.rma_id
|
rma = self.rma_id
|
||||||
data_rma = self._get_rma_data()
|
data_rma = self._get_rma_data()
|
||||||
rma.write(data_rma)
|
rma.write(data_rma)
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return {"type": "ir.actions.act_window_close"}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_rma_add_purchase" model="ir.ui.view">
|
<record id="view_rma_add_purchase" model="ir.ui.view">
|
||||||
<field name="name">rma.add.purchase</field>
|
<field name="name">rma.add.purchase</field>
|
||||||
@@ -7,21 +6,27 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Select Purchase Order from customer">
|
<form string="Select Purchase Order from customer">
|
||||||
<group>
|
<group>
|
||||||
<field name="partner_id"
|
<field
|
||||||
|
name="partner_id"
|
||||||
domain="[('customer','=',True)]"
|
domain="[('customer','=',True)]"
|
||||||
string="Customer"/>
|
string="Customer"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<separator string="Select Purchase Order from customer" />
|
<separator string="Select Purchase Order from customer" />
|
||||||
<group>
|
<group>
|
||||||
<field name="purchase_id"
|
<field
|
||||||
|
name="purchase_id"
|
||||||
domain="[
|
domain="[
|
||||||
('partner_id','=',partner_id), (('state','not in',['draft','cancel']))]"
|
('partner_id','=',partner_id), (('state','not in',['draft','cancel']))]"
|
||||||
context="{'partner_id': partner_id}"/>
|
context="{'partner_id': partner_id}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<separator string="Select Purchase Order Lines to Add" />
|
<separator string="Select Purchase Order Lines to Add" />
|
||||||
<field name="purchase_line_ids"
|
<field
|
||||||
|
name="purchase_line_ids"
|
||||||
domain="[('order_id', '=', purchase_id)]"
|
domain="[('order_id', '=', purchase_id)]"
|
||||||
string="Purchase Order Lines">
|
string="Purchase Order Lines"
|
||||||
|
>
|
||||||
<tree string="Purchase Order Lines">
|
<tree string="Purchase Order Lines">
|
||||||
<field name="order_id" />
|
<field name="order_id" />
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
@@ -37,11 +42,17 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<button
|
<button
|
||||||
string="Confirm"
|
string="Confirm"
|
||||||
name="add_lines" type="object"
|
name="add_lines"
|
||||||
class="oe_highlight"/>
|
type="object"
|
||||||
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
or
|
or
|
||||||
<button name="action_cancel"
|
<button
|
||||||
string="Cancel" class="oe_link" special="cancel"/>
|
name="action_cancel"
|
||||||
|
string="Cancel"
|
||||||
|
class="oe_link"
|
||||||
|
special="cancel"
|
||||||
|
/>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
@@ -56,7 +67,10 @@
|
|||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="view_id" ref="view_rma_add_purchase" />
|
<field name="view_id" ref="view_rma_add_purchase" />
|
||||||
<field name="groups_id" eval="[(4, ref('rma.group_rma_customer_user')), (4, ref('rma.group_rma_customer_user'))]"/>
|
<field
|
||||||
|
name="groups_id"
|
||||||
|
eval="[(4, ref('rma.group_rma_customer_user')), (4, ref('rma.group_rma_customer_user'))]"
|
||||||
|
/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_rma_add_purchase_button_form" model="ir.ui.view">
|
<record id="view_rma_add_purchase_button_form" model="ir.ui.view">
|
||||||
@@ -65,9 +79,11 @@
|
|||||||
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
|
<field name="inherit_id" ref="rma.view_rma_supplier_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//header" position="inside">
|
<xpath expr="//header" position="inside">
|
||||||
<button name="%(action_rma_add_purchase)d"
|
<button
|
||||||
|
name="%(action_rma_add_purchase)d"
|
||||||
string="Add From Purchase Order"
|
string="Add From Purchase Order"
|
||||||
type="action"/>
|
type="action"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -5,34 +5,33 @@ from odoo import api, fields, models
|
|||||||
|
|
||||||
|
|
||||||
class RmaMakePicking(models.TransientModel):
|
class RmaMakePicking(models.TransientModel):
|
||||||
_inherit = 'rma_make_picking.wizard'
|
_inherit = "rma_make_picking.wizard"
|
||||||
|
|
||||||
@api.returns('rma.order.line')
|
@api.returns("rma.order.line")
|
||||||
def _prepare_item(self, line):
|
def _prepare_item(self, line):
|
||||||
res = super(RmaMakePicking, self)._prepare_item(line)
|
res = super(RmaMakePicking, self)._prepare_item(line)
|
||||||
res['purchase_order_line_id'] = line.purchase_order_line_id.id
|
res["purchase_order_line_id"] = line.purchase_order_line_id.id
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_action(self, pickings, procurements):
|
def _get_action(self, pickings, procurements):
|
||||||
po_list = []
|
po_list = []
|
||||||
for procurement in procurements:
|
for procurement in procurements:
|
||||||
if procurement.purchase_id and \
|
if procurement.purchase_id and procurement.purchase_id.id:
|
||||||
procurement.purchase_id.id:
|
|
||||||
po_list.append(procurement.purchase_id.id)
|
po_list.append(procurement.purchase_id.id)
|
||||||
if len(po_list):
|
if len(po_list):
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
action = self.env.ref("purchase.purchase_rfq")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
result['domain'] = [('id', 'in', po_list)]
|
result["domain"] = [("id", "in", po_list)]
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
action = super(RmaMakePicking, self)._get_action(pickings,
|
action = super(RmaMakePicking, self)._get_action(pickings, procurements)
|
||||||
procurements)
|
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
class RmaMakePickingItem(models.TransientModel):
|
class RmaMakePickingItem(models.TransientModel):
|
||||||
_inherit = "rma_make_picking.wizard.item"
|
_inherit = "rma_make_picking.wizard.item"
|
||||||
|
|
||||||
purchase_order_line_id = fields.Many2one('purchase.order.line',
|
purchase_order_line_id = fields.Many2one(
|
||||||
string='Purchase Line')
|
"purchase.order.line", string="Purchase Line"
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,74 +1,86 @@
|
|||||||
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
|
||||||
|
|
||||||
import odoo.addons.decimal_precision as dp
|
|
||||||
from odoo import fields, models, api, _, exceptions
|
|
||||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DF
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from odoo import _, api, exceptions, fields, models
|
||||||
|
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DF
|
||||||
|
|
||||||
|
import odoo.addons.decimal_precision as dp
|
||||||
|
|
||||||
|
|
||||||
class RmaLineMakePurchaseOrder(models.TransientModel):
|
class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||||
_name = "rma.order.line.make.purchase.order"
|
_name = "rma.order.line.make.purchase.order"
|
||||||
_description = "Make Purchases Order from RMA Line"
|
_description = "Make Purchases Order from RMA Line"
|
||||||
|
|
||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
comodel_name='res.partner', string='Supplier', required=False,
|
comodel_name="res.partner",
|
||||||
domain=[('supplier', '=', True)], readonly=1)
|
string="Supplier",
|
||||||
|
required=False,
|
||||||
|
domain=[("supplier", "=", True)],
|
||||||
|
readonly=1,
|
||||||
|
)
|
||||||
item_ids = fields.One2many(
|
item_ids = fields.One2many(
|
||||||
comodel_name='rma.order.line.make.purchase.order.item',
|
comodel_name="rma.order.line.make.purchase.order.item",
|
||||||
inverse_name='wiz_id', string='Items')
|
inverse_name="wiz_id",
|
||||||
|
string="Items",
|
||||||
|
)
|
||||||
purchase_order_id = fields.Many2one(
|
purchase_order_id = fields.Many2one(
|
||||||
comodel_name='purchase.order', string='Purchases Order',
|
comodel_name="purchase.order",
|
||||||
required=False, domain=[('state', '=', 'draft')])
|
string="Purchases Order",
|
||||||
|
required=False,
|
||||||
|
domain=[("state", "=", "draft")],
|
||||||
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_item(self, line):
|
def _prepare_item(self, line):
|
||||||
return {
|
return {
|
||||||
'line_id': line.id,
|
"line_id": line.id,
|
||||||
'rma_line_id': line.id,
|
"rma_line_id": line.id,
|
||||||
'product_id': line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
'name': line.product_id.name,
|
"name": line.product_id.name,
|
||||||
'product_qty': line.qty_to_purchase,
|
"product_qty": line.qty_to_purchase,
|
||||||
'rma_id': line.rma_id.id,
|
"rma_id": line.rma_id.id,
|
||||||
'product_uom_id': line.uom_id.id,
|
"product_uom_id": line.uom_id.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields_list):
|
def default_get(self, fields_list):
|
||||||
res = super(RmaLineMakePurchaseOrder, self).default_get(
|
res = super(RmaLineMakePurchaseOrder, self).default_get(fields_list)
|
||||||
fields_list)
|
rma_line_obj = self.env["rma.order.line"]
|
||||||
rma_line_obj = self.env['rma.order.line']
|
rma_line_ids = self.env.context["active_ids"] or []
|
||||||
rma_line_ids = self.env.context['active_ids'] or []
|
active_model = self.env.context["active_model"]
|
||||||
active_model = self.env.context['active_model']
|
|
||||||
|
|
||||||
if not rma_line_ids:
|
if not rma_line_ids:
|
||||||
return res
|
return res
|
||||||
assert active_model == 'rma.order.line', 'Bad context propagation'
|
assert active_model == "rma.order.line", "Bad context propagation"
|
||||||
|
|
||||||
items = []
|
items = []
|
||||||
lines = rma_line_obj.browse(rma_line_ids)
|
lines = rma_line_obj.browse(rma_line_ids)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
items.append([0, 0, self._prepare_item(line)])
|
items.append([0, 0, self._prepare_item(line)])
|
||||||
suppliers = lines.mapped('partner_id')
|
suppliers = lines.mapped("partner_id")
|
||||||
if len(suppliers) == 1:
|
if len(suppliers) == 1:
|
||||||
res['partner_id'] = suppliers.id
|
res["partner_id"] = suppliers.id
|
||||||
else:
|
else:
|
||||||
raise exceptions.Warning(
|
raise exceptions.Warning(
|
||||||
_('Only RMA lines from the same partner can be processed at '
|
_(
|
||||||
'the same time'))
|
"Only RMA lines from the same partner can be processed at "
|
||||||
res['item_ids'] = items
|
"the same time"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
res["item_ids"] = items
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_purchase_order(self, item):
|
def _prepare_purchase_order(self, item):
|
||||||
if not self.partner_id:
|
if not self.partner_id:
|
||||||
raise exceptions.Warning(
|
raise exceptions.Warning(_("Enter a supplier."))
|
||||||
_('Enter a supplier.'))
|
|
||||||
supplier = self.partner_id
|
supplier = self.partner_id
|
||||||
data = {
|
data = {
|
||||||
'origin': '',
|
"origin": "",
|
||||||
'partner_id': supplier.id,
|
"partner_id": supplier.id,
|
||||||
'company_id': item.line_id.company_id.id,
|
"company_id": item.line_id.company_id.id,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -76,29 +88,28 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
|||||||
def _prepare_purchase_order_line(self, po, item):
|
def _prepare_purchase_order_line(self, po, item):
|
||||||
product = item.product_id
|
product = item.product_id
|
||||||
vals = {
|
vals = {
|
||||||
'name': product.name,
|
"name": product.name,
|
||||||
'order_id': po.id,
|
"order_id": po.id,
|
||||||
'product_id': product.id,
|
"product_id": product.id,
|
||||||
'price_unit': item.line_id.price_unit,
|
"price_unit": item.line_id.price_unit,
|
||||||
'date_planned': datetime.today().strftime(DF),
|
"date_planned": datetime.today().strftime(DF),
|
||||||
'product_uom': product.uom_po_id.id,
|
"product_uom": product.uom_po_id.id,
|
||||||
'product_qty': item.product_qty,
|
"product_qty": item.product_qty,
|
||||||
'rma_line_id': item.line_id.id
|
"rma_line_id": item.line_id.id,
|
||||||
}
|
}
|
||||||
if item.free_of_charge:
|
if item.free_of_charge:
|
||||||
vals['price_unit'] = 0.0
|
vals["price_unit"] = 0.0
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def create_purchase_order(self):
|
def create_purchase_order(self):
|
||||||
res = []
|
res = []
|
||||||
purchase_obj = self.env['purchase.order']
|
purchase_obj = self.env["purchase.order"]
|
||||||
po_line_obj = self.env['purchase.order.line']
|
po_line_obj = self.env["purchase.order.line"]
|
||||||
|
|
||||||
for item in self.item_ids:
|
for item in self.item_ids:
|
||||||
if item.product_qty <= 0.0:
|
if item.product_qty <= 0.0:
|
||||||
raise exceptions.Warning(
|
raise exceptions.Warning(_("Enter a positive quantity."))
|
||||||
_('Enter a positive quantity.'))
|
|
||||||
|
|
||||||
purchase = self.purchase_order_id
|
purchase = self.purchase_order_id
|
||||||
if not purchase:
|
if not purchase:
|
||||||
@@ -109,9 +120,9 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
|||||||
po_line_obj.create(po_line_data)
|
po_line_obj.create(po_line_data)
|
||||||
res.append(purchase.id)
|
res.append(purchase.id)
|
||||||
|
|
||||||
action = self.env.ref('purchase.purchase_rfq')
|
action = self.env.ref("purchase.purchase_rfq")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
result['domain'] = "[('id','in', ["+','.join(map(str, res))+"])]"
|
result["domain"] = "[('id','in', [" + ",".join(map(str, res)) + "])]"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -120,18 +131,17 @@ class RmaLineMakePurchaseOrderItem(models.TransientModel):
|
|||||||
_description = "RMA Line Make Purchase Order Item"
|
_description = "RMA Line Make Purchase Order Item"
|
||||||
|
|
||||||
wiz_id = fields.Many2one(
|
wiz_id = fields.Many2one(
|
||||||
comodel_name='rma.order.line.make.purchase.order', string='Wizard')
|
comodel_name="rma.order.line.make.purchase.order", string="Wizard"
|
||||||
line_id = fields.Many2one(
|
)
|
||||||
comodel_name='rma.order.line', string='RMA Line')
|
line_id = fields.Many2one(comodel_name="rma.order.line", string="RMA Line")
|
||||||
rma_id = fields.Many2one(
|
rma_id = fields.Many2one(
|
||||||
comodel_name='rma.order', related='line_id.rma_id',
|
comodel_name="rma.order", related="line_id.rma_id", string="RMA Order"
|
||||||
string='RMA Order')
|
)
|
||||||
product_id = fields.Many2one(
|
product_id = fields.Many2one(comodel_name="product.product", string="Product")
|
||||||
comodel_name='product.product', string='Product')
|
name = fields.Char(string="Description")
|
||||||
name = fields.Char(string='Description')
|
|
||||||
product_qty = fields.Float(
|
product_qty = fields.Float(
|
||||||
string='Quantity to purchase',
|
string="Quantity to purchase",
|
||||||
digits=dp.get_precision('Product Unit of Measure'),)
|
digits=dp.get_precision("Product Unit of Measure"),
|
||||||
product_uom_id = fields.Many2one(
|
)
|
||||||
comodel_name='uom.uom', string='UoM')
|
product_uom_id = fields.Many2one(comodel_name="uom.uom", string="UoM")
|
||||||
free_of_charge = fields.Boolean(string='Free of Charge')
|
free_of_charge = fields.Boolean(string="Free of Charge")
|
||||||
|
|||||||
@@ -9,13 +9,14 @@
|
|||||||
<separator string="Existing Quotation to update:" />
|
<separator string="Existing Quotation to update:" />
|
||||||
<newline />
|
<newline />
|
||||||
<group>
|
<group>
|
||||||
<field name="purchase_order_id"
|
<field
|
||||||
|
name="purchase_order_id"
|
||||||
domain="[('partner_id','=',partner_id)]"
|
domain="[('partner_id','=',partner_id)]"
|
||||||
context="{'partner_id': partner_id}"/>
|
context="{'partner_id': partner_id}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<newline />
|
<newline />
|
||||||
<separator
|
<separator string="New Purchases Order details:" />
|
||||||
string="New Purchases Order details:"/>
|
|
||||||
<newline />
|
<newline />
|
||||||
<group>
|
<group>
|
||||||
<field name="partner_id" />
|
<field name="partner_id" />
|
||||||
@@ -23,31 +24,44 @@
|
|||||||
<newline />
|
<newline />
|
||||||
<group>
|
<group>
|
||||||
<field name="item_ids" nolabel="1" colspan="2">
|
<field name="item_ids" nolabel="1" colspan="2">
|
||||||
<tree string="Details" editable="bottom" create="false">
|
<tree
|
||||||
<field name="line_id"
|
string="Details"
|
||||||
options="{'no_open': true}"/>
|
editable="bottom"
|
||||||
|
create="false"
|
||||||
|
>
|
||||||
|
<field
|
||||||
|
name="line_id"
|
||||||
|
options="{'no_open': true}"
|
||||||
|
/>
|
||||||
<field name="product_id" />
|
<field name="product_id" />
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="product_qty" />
|
<field name="product_qty" />
|
||||||
<field name="product_uom_id"
|
<field
|
||||||
groups="uom.group_uom"/>
|
name="product_uom_id"
|
||||||
|
groups="uom.group_uom"
|
||||||
|
/>
|
||||||
<field name="free_of_charge" />
|
<field name="free_of_charge" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<newline />
|
<newline />
|
||||||
<footer colspan="2">
|
<footer colspan="2">
|
||||||
<button name="create_purchase_order"
|
<button
|
||||||
string="Create RFQ" type="object"
|
name="create_purchase_order"
|
||||||
class="oe_highlight"/>
|
string="Create RFQ"
|
||||||
|
type="object"
|
||||||
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
<button special="cancel" string="Cancel" class="oe_link" />
|
<button special="cancel" string="Cancel" class="oe_link" />
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_order_line_make_purchase_order"
|
<record
|
||||||
model="ir.actions.act_window">
|
id="action_rma_order_line_make_purchase_order"
|
||||||
|
model="ir.actions.act_window"
|
||||||
|
>
|
||||||
<field name="name">Create RFQ</field>
|
<field name="name">Create RFQ</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma.order.line.make.purchase.order</field>
|
<field name="res_model">rma.order.line.make.purchase.order</field>
|
||||||
@@ -58,4 +72,3 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user