[13.0][MIG] rma_purchase

This commit is contained in:
Chanakya-SerpentCS
2020-12-15 17:54:46 +05:30
committed by Chanakya Soni
parent 55c0b05234
commit c76a65f887
13 changed files with 15 additions and 44 deletions

View File

@@ -8,9 +8,9 @@ class PurchaseOrder(models.Model):
_inherit = "purchase.order" _inherit = "purchase.order"
@api.model @api.model
def new(self, vals): def new(self, vals, origin=None, ref=None):
"""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, origin=origin, ref=ref)
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)

View File

@@ -36,12 +36,11 @@ class PurchaseOrderLine(models.Model):
name_get_uid=name_get_uid, name_get_uid=name_get_uid,
) )
@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.move.line"].search(
[("purchase_line_id", "=", purchase.id)] [("purchase_line_id", "=", purchase.id)]
) )
if purchase.order_id.name: if purchase.order_id.name:
@@ -54,8 +53,7 @@ class PurchaseOrderLine(models.Model):
" ".join( " ".join(
str(x) str(x)
for x in [ for x in [
inv.number inv.name for inv in invoices.mapped("move_id")
for inv in invoices.mapped("invoice_id")
] ]
), ),
purchase.product_id.name, purchase.product_id.name,

View File

@@ -18,7 +18,6 @@ class RmaOperation(models.Model):
default="no", default="no",
) )
@api.multi
@api.constrains("purchase_policy") @api.constrains("purchase_policy")
def _check_purchase_policy(self): def _check_purchase_policy(self):
if self.filtered(lambda r: r.purchase_policy != "no" and r.type != "supplier"): if self.filtered(lambda r: r.purchase_policy != "no" and r.type != "supplier"):

View File

@@ -7,7 +7,6 @@ from odoo import api, fields, models
class RmaOrder(models.Model): class RmaOrder(models.Model):
_inherit = "rma.order" _inherit = "rma.order"
@api.multi
def _compute_po_count(self): def _compute_po_count(self):
for rec in self: for rec in self:
po_count = 0 po_count = 0
@@ -20,7 +19,6 @@ class RmaOrder(models.Model):
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.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:
@@ -32,7 +30,6 @@ class RmaOrder(models.Model):
compute="_compute_origin_po_count", string="# of Origin PO" compute="_compute_origin_po_count", string="# of Origin PO"
) )
@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]
@@ -44,7 +41,6 @@ class RmaOrder(models.Model):
result["domain"] = [("id", "in", po_ids)] result["domain"] = [("id", "in", po_ids)]
return result return result
@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]

View File

@@ -10,7 +10,6 @@ from odoo.addons import decimal_precision as dp
class RmaOrderLine(models.Model): class RmaOrderLine(models.Model):
_inherit = "rma.order.line" _inherit = "rma.order.line"
@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(
@@ -18,7 +17,6 @@ class RmaOrderLine(models.Model):
) )
rec.purchase_count = len(purchase_line_count.mapped("order_id")) rec.purchase_count = len(purchase_line_count.mapped("order_id"))
@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 = []
@@ -28,7 +26,6 @@ class RmaOrderLine(models.Model):
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)]
@api.multi
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()
@@ -118,7 +115,6 @@ class RmaOrderLine(models.Model):
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
def _prepare_rma_line_from_po_line(self, line): def _prepare_rma_line_from_po_line(self, line):
self.ensure_one() self.ensure_one()
if not self.type: if not self.type:
@@ -194,7 +190,6 @@ class RmaOrderLine(models.Model):
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.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:
@@ -209,14 +204,12 @@ class RmaOrderLine(models.Model):
) )
) )
@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
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]
@@ -224,7 +217,6 @@ class RmaOrderLine(models.Model):
result["domain"] = [("id", "in", orders.ids)] result["domain"] = [("id", "in", orders.ids)]
return result return result
@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

View File

@@ -4,7 +4,6 @@
<record id="action_rma_line_purchase" model="ir.actions.act_window"> <record id="action_rma_line_purchase" model="ir.actions.act_window">
<field name="name">Purchase Order</field> <field name="name">Purchase Order</field>
<field name="res_model">purchase.order</field> <field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="target">current</field> <field name="target">current</field>
<field name="view_mode">form,tree</field> <field name="view_mode">form,tree</field>
</record> </record>

View File

@@ -14,11 +14,7 @@
icon="fa-shopping-cart" icon="fa-shopping-cart"
groups="purchase.group_purchase_user" groups="purchase.group_purchase_user"
> >
<field <field name="po_count" widget="statinfo" string="Purchase Orders" />
name="po_count"
widget="statinfo"
string="Purchase Orders"
/>
</button> </button>
<button <button
type="object" type="object"

View File

@@ -122,7 +122,6 @@ class RmaAddPurchase(models.TransientModel):
existing_purchase_lines.append(rma_line.purchase_order_line_id) existing_purchase_lines.append(rma_line.purchase_order_line_id)
return existing_purchase_lines return existing_purchase_lines
@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()

View File

@@ -62,8 +62,6 @@
<field name="name">Add Purchase Order</field> <field name="name">Add Purchase Order</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">rma_add_purchase</field> <field name="res_model">rma_add_purchase</field>
<field name="src_model">rma.order</field>
<field name="view_type">form</field>
<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" />

View File

@@ -36,7 +36,6 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
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,
"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,
@@ -101,7 +100,6 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
vals["price_unit"] = 0.0 vals["price_unit"] = 0.0
return vals return vals
@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"]

View File

@@ -24,22 +24,12 @@
<newline /> <newline />
<group> <group>
<field name="item_ids" nolabel="1" colspan="2"> <field name="item_ids" nolabel="1" colspan="2">
<tree <tree string="Details" editable="bottom" create="false">
string="Details" <field name="line_id" 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 <field name="product_uom_id" 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>
@@ -65,7 +55,6 @@
<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>
<field name="view_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="view_id" ref="view_rma_order_line_make_purchase_order" /> <field name="view_id" ref="view_rma_order_line_make_purchase_order" />
<field name="target">new</field> <field name="target">new</field>

View File

@@ -0,0 +1 @@
../../../../rma_purchase

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)