mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma_purchase: Migration to 14.0
This commit is contained in:
committed by
Jordi Ballester Alomar
parent
5e0d08aa5b
commit
1cb2277c5e
@@ -3,12 +3,12 @@
|
||||
|
||||
{
|
||||
"name": "RMA Purchase",
|
||||
"version": "12.0.1.0.0",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "RMA",
|
||||
"summary": "RMA from PO",
|
||||
"license": "LGPL-3",
|
||||
"author": "Eficent, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/account-budgeting",
|
||||
"website": "https://github.com/OCA/https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["rma_account", "purchase"],
|
||||
"data": [
|
||||
"wizards/rma_order_line_make_purchase_order_view.xml",
|
||||
|
||||
@@ -8,7 +8,7 @@ class PurchaseOrder(models.Model):
|
||||
_inherit = "purchase.order"
|
||||
|
||||
@api.model
|
||||
def new(self, vals):
|
||||
def new(self, vals, origin=None, ref=None):
|
||||
"""Allows to propose a line based on the RMA information."""
|
||||
res = super(PurchaseOrder, self).new(vals)
|
||||
rma_line_id = self.env.context.get("rma_line_id")
|
||||
|
||||
@@ -39,12 +39,11 @@ class PurchaseOrderLine(models.Model):
|
||||
name_get_uid=name_get_uid,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def name_get(self):
|
||||
res = []
|
||||
if self.env.context.get("rma"):
|
||||
for purchase in self:
|
||||
invoices = self.env["account.invoice.line"].search(
|
||||
invoices = self.env["account.move.line"].search(
|
||||
[("purchase_line_id", "=", purchase.id)]
|
||||
)
|
||||
if purchase.order_id.name:
|
||||
@@ -57,8 +56,7 @@ class PurchaseOrderLine(models.Model):
|
||||
" ".join(
|
||||
str(x)
|
||||
for x in [
|
||||
inv.number
|
||||
for inv in invoices.mapped("invoice_id")
|
||||
inv.name for inv in invoices.mapped("move_id")
|
||||
]
|
||||
),
|
||||
purchase.product_id.name,
|
||||
|
||||
@@ -18,7 +18,6 @@ class RmaOperation(models.Model):
|
||||
default="no",
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@api.constrains("purchase_policy")
|
||||
def _check_purchase_policy(self):
|
||||
if self.filtered(lambda r: r.purchase_policy != "no" and r.type != "supplier"):
|
||||
|
||||
@@ -7,7 +7,6 @@ from odoo import api, fields, models
|
||||
class RmaOrder(models.Model):
|
||||
_inherit = "rma.order"
|
||||
|
||||
@api.multi
|
||||
def _compute_po_count(self):
|
||||
for rec in self:
|
||||
po_count = 0
|
||||
@@ -20,7 +19,6 @@ class RmaOrder(models.Model):
|
||||
po_count = len(list(set(rma_line_po)))
|
||||
rec.po_count = po_count
|
||||
|
||||
@api.multi
|
||||
@api.depends("rma_line_ids")
|
||||
def _compute_origin_po_count(self):
|
||||
for rma in self:
|
||||
@@ -32,7 +30,6 @@ class RmaOrder(models.Model):
|
||||
compute="_compute_origin_po_count", string="# of Origin PO"
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_view_purchase_order(self):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
@@ -44,7 +41,6 @@ class RmaOrder(models.Model):
|
||||
result["domain"] = [("id", "in", po_ids)]
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def action_view_origin_purchase_order(self):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
|
||||
@@ -10,7 +10,6 @@ from odoo.addons import decimal_precision as dp
|
||||
class RmaOrderLine(models.Model):
|
||||
_inherit = "rma.order.line"
|
||||
|
||||
@api.multi
|
||||
def _compute_purchase_count(self):
|
||||
for rec in self:
|
||||
purchase_line_count = self.env["purchase.order.line"].search(
|
||||
@@ -18,7 +17,6 @@ class RmaOrderLine(models.Model):
|
||||
)
|
||||
rec.purchase_count = len(purchase_line_count.mapped("order_id"))
|
||||
|
||||
@api.multi
|
||||
def _compute_purchase_order_lines(self):
|
||||
for rec in self:
|
||||
purchase_list = []
|
||||
@@ -28,7 +26,6 @@ class RmaOrderLine(models.Model):
|
||||
purchase_list.append(line.id)
|
||||
rec.purchase_order_line_ids = [(6, 0, purchase_list)]
|
||||
|
||||
@api.multi
|
||||
def _compute_qty_purchase(self):
|
||||
for rec in self:
|
||||
rec.qty_purchased = rec._get_rma_purchased_qty()
|
||||
@@ -119,7 +116,6 @@ class RmaOrderLine(models.Model):
|
||||
self.purchase_policy = self.operation_id.purchase_policy or "no"
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _prepare_rma_line_from_po_line(self, line):
|
||||
self.ensure_one()
|
||||
if not self.type:
|
||||
@@ -195,7 +191,6 @@ class RmaOrderLine(models.Model):
|
||||
self.update(data)
|
||||
self._remove_other_data_origin("purchase_order_line_id")
|
||||
|
||||
@api.multi
|
||||
@api.constrains("purchase_order_line_id", "partner_id")
|
||||
def _check_purchase_partner(self):
|
||||
for rec in self:
|
||||
@@ -210,14 +205,12 @@ class RmaOrderLine(models.Model):
|
||||
)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _remove_other_data_origin(self, exception):
|
||||
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
||||
if not exception == "purchase_order_line_id":
|
||||
self.purchase_order_line_id = False
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def action_view_purchase_order(self):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
@@ -225,7 +218,6 @@ class RmaOrderLine(models.Model):
|
||||
result["domain"] = [("id", "in", orders.ids)]
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def _get_rma_purchased_qty(self):
|
||||
self.ensure_one()
|
||||
qty = 0.0
|
||||
|
||||
6
rma_purchase/security/ir.model.access.csv
Executable file → Normal file
6
rma_purchase/security/ir.model.access.csv
Executable file → Normal file
@@ -1,3 +1,9 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_purchase_order_supplier_user,access_purchase_order,purchase.model_purchase_order,rma.group_rma_supplier_user,1,0,0,0
|
||||
access_purchase_order_line_supplier_user,access_purchase_order_line,purchase.model_purchase_order_line,rma.group_rma_supplier_user,1,0,0,0
|
||||
access_rma_order_line_make_purchase_order_customer_user_item,rma.order.line.make.purchase.order.customer.user,model_rma_order_line_make_purchase_order,rma.group_rma_customer_user,1,1,1,1
|
||||
access_rma_order_line_make_purchase_order_supplier_user_item,rma.order.line.make.purchase.order.supplier.user,model_rma_order_line_make_purchase_order,rma.group_rma_supplier_user,1,1,1,1
|
||||
access_rma_order_line_make_purchase_order_item_customer_user_item,rma.order.line.make.purchase.order.item.customer.user,model_rma_order_line_make_purchase_order_item,rma.group_rma_customer_user,1,1,1,1
|
||||
access_rma_order_line_make_purchase_order_item_supplier_user_item,rma.order.line.make.purchase.order.item.supplier.user,model_rma_order_line_make_purchase_order_item,rma.group_rma_supplier_user,1,1,1,1
|
||||
access_rma_add_purchase_customer_user_item,rma.add.purchase.customer.user,model_rma_add_purchase,rma.group_rma_customer_user,1,1,1,1
|
||||
access_rma_add_purchase_supplier_user_item,rma.add.purchase.supplier.user,model_rma_add_purchase,rma.group_rma_supplier_user,1,1,1,1
|
||||
|
||||
|
@@ -4,7 +4,6 @@
|
||||
<record id="action_rma_line_purchase" model="ir.actions.act_window">
|
||||
<field name="name">Purchase Order</field>
|
||||
<field name="res_model">purchase.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="target">current</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
</record>
|
||||
|
||||
@@ -122,7 +122,6 @@ class RmaAddPurchase(models.TransientModel):
|
||||
existing_purchase_lines.append(rma_line.purchase_order_line_id)
|
||||
return existing_purchase_lines
|
||||
|
||||
@api.multi
|
||||
def add_lines(self):
|
||||
rma_line_obj = self.env["rma.order.line"]
|
||||
existing_purchase_lines = self._get_existing_purchase_lines()
|
||||
|
||||
@@ -6,11 +6,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select Purchase Order from customer">
|
||||
<group>
|
||||
<field
|
||||
name="partner_id"
|
||||
domain="[('customer','=',True)]"
|
||||
string="Customer"
|
||||
/>
|
||||
<field name="partner_id" string="Customer" />
|
||||
</group>
|
||||
<separator string="Select Purchase Order from customer" />
|
||||
<group>
|
||||
@@ -62,8 +58,7 @@
|
||||
<field name="name">Add Purchase Order</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">rma_add_purchase</field>
|
||||
<field name="src_model">rma.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="binding_model_id" ref="rma.model_rma_order" />
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="view_rma_add_purchase" />
|
||||
|
||||
@@ -7,7 +7,6 @@ from odoo import api, fields, models
|
||||
class RmaMakePicking(models.TransientModel):
|
||||
_inherit = "rma_make_picking.wizard"
|
||||
|
||||
@api.returns("rma.order.line")
|
||||
def _prepare_item(self, line):
|
||||
res = super(RmaMakePicking, self)._prepare_item(line)
|
||||
res["purchase_order_line_id"] = line.purchase_order_line_id.id
|
||||
|
||||
@@ -15,9 +15,7 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name="res.partner",
|
||||
string="Supplier",
|
||||
required=False,
|
||||
domain=[("supplier", "=", True)],
|
||||
readonly=1,
|
||||
)
|
||||
item_ids = fields.One2many(
|
||||
@@ -101,7 +99,6 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
vals["price_unit"] = 0.0
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def create_purchase_order(self):
|
||||
res = []
|
||||
purchase_obj = self.env["purchase.order"]
|
||||
@@ -145,3 +142,6 @@ class RmaLineMakePurchaseOrderItem(models.TransientModel):
|
||||
)
|
||||
product_uom_id = fields.Many2one(comodel_name="uom.uom", string="UoM")
|
||||
free_of_charge = fields.Boolean(string="Free of Charge")
|
||||
rma_line_id = fields.Many2one(
|
||||
comodel_name="rma.order", string="RMA", ondelete="set null"
|
||||
)
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
<field name="name">Create RFQ</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">rma.order.line.make.purchase.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_rma_order_line_make_purchase_order" />
|
||||
<field name="target">new</field>
|
||||
|
||||
Reference in New Issue
Block a user