mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[13.0][MIG] rma_purchase
This commit is contained in:
committed by
Chanakya Soni
parent
55c0b05234
commit
c76a65f887
@@ -8,9 +8,9 @@ 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)
|
||||
res = super(PurchaseOrder, self).new(vals, origin=origin, ref=ref)
|
||||
rma_line_id = self.env.context.get("rma_line_id")
|
||||
if rma_line_id:
|
||||
rma_line = self.env["rma.order.line"].browse(rma_line_id)
|
||||
|
||||
@@ -36,12 +36,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:
|
||||
@@ -54,8 +53,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()
|
||||
@@ -118,7 +115,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:
|
||||
@@ -194,7 +190,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:
|
||||
@@ -209,14 +204,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]
|
||||
@@ -224,7 +217,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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
icon="fa-shopping-cart"
|
||||
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
|
||||
type="object"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -62,8 +62,6 @@
|
||||
<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="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="view_rma_add_purchase" />
|
||||
|
||||
@@ -36,7 +36,6 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
def _prepare_item(self, line):
|
||||
return {
|
||||
"line_id": line.id,
|
||||
"rma_line_id": line.id,
|
||||
"product_id": line.product_id.id,
|
||||
"name": line.product_id.name,
|
||||
"product_qty": line.qty_to_purchase,
|
||||
@@ -101,7 +100,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"]
|
||||
|
||||
@@ -24,22 +24,12 @@
|
||||
<newline />
|
||||
<group>
|
||||
<field name="item_ids" nolabel="1" colspan="2">
|
||||
<tree
|
||||
string="Details"
|
||||
editable="bottom"
|
||||
create="false"
|
||||
>
|
||||
<field
|
||||
name="line_id"
|
||||
options="{'no_open': true}"
|
||||
/>
|
||||
<tree string="Details" editable="bottom" create="false">
|
||||
<field name="line_id" options="{'no_open': true}" />
|
||||
<field name="product_id" />
|
||||
<field name="name" />
|
||||
<field name="product_qty" />
|
||||
<field
|
||||
name="product_uom_id"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field name="product_uom_id" groups="uom.group_uom" />
|
||||
<field name="free_of_charge" />
|
||||
</tree>
|
||||
</field>
|
||||
@@ -65,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>
|
||||
|
||||
1
setup/rma_purchase/odoo/addons/rma_purchase
Symbolic link
1
setup/rma_purchase/odoo/addons/rma_purchase
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../rma_purchase
|
||||
6
setup/rma_purchase/setup.py
Normal file
6
setup/rma_purchase/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user