mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma_account: Migration to 14.0
This commit is contained in:
committed by
AaronHForgeFlow
parent
d36fc19d29
commit
f7011aa598
@@ -3,12 +3,12 @@
|
||||
|
||||
{
|
||||
"name": "RMA Account",
|
||||
"version": "13.0.1.0.0",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "Integrates RMA with Invoice Processing",
|
||||
"author": "ForgeFlow",
|
||||
"website": "https://github.com/OCA/account-budgeting",
|
||||
"website": "https://github.com/OCA/https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["stock_account", "rma"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
|
||||
@@ -103,7 +103,6 @@ class RmaOrder(models.Model):
|
||||
"domain": [("id", "in", move_ids)],
|
||||
"name": "Refunds",
|
||||
"res_model": "account.move",
|
||||
"type": "ir.actions.act_window",
|
||||
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
|
||||
}
|
||||
|
||||
@@ -116,6 +115,5 @@ class RmaOrder(models.Model):
|
||||
"domain": [("id", "in", move_ids)],
|
||||
"name": "Originating Invoice",
|
||||
"res_model": "account.move",
|
||||
"type": "ir.actions.act_window",
|
||||
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
|
||||
}
|
||||
|
||||
@@ -119,17 +119,25 @@ class RmaOrderLine(models.Model):
|
||||
res = super(RmaOrderLine, self)._onchange_product_id()
|
||||
if not res.get("domain"):
|
||||
res["domain"] = {}
|
||||
if not self.product_id:
|
||||
domain = [
|
||||
"&",
|
||||
"&",
|
||||
("rma_line_id", "=", False),
|
||||
("exclude_from_invoice_tab", "=", False),
|
||||
"|",
|
||||
("move_id.partner_id", "=", self.partner_id.id),
|
||||
("move_id.partner_id", "child_of", self.partner_id.id),
|
||||
("exclude_from_invoice_tab", "=", False),
|
||||
]
|
||||
res["domain"]["account_move_line_id"] = domain
|
||||
else:
|
||||
domain = [
|
||||
"&",
|
||||
"&",
|
||||
"|",
|
||||
("move_id.partner_id", "=", self.partner_id.id),
|
||||
("move_id.partner_id", "child_of", self.partner_id.id),
|
||||
("exclude_from_invoice_tab", "=", False),
|
||||
("product_id", "=", self.product_id.id),
|
||||
]
|
||||
# if self.product_id:
|
||||
# domain.insert(2, ("product_id", "=", self.product_id.id))
|
||||
res["domain"]["account_move_line_id"] = domain
|
||||
return res
|
||||
|
||||
|
||||
@@ -3,3 +3,9 @@ access_account_move_customer_user,access_account_move,account.model_account_move
|
||||
access_account_move_supplier_user,access_account_move,account.model_account_move,rma.group_rma_supplier_user,1,0,0,0
|
||||
access_account_move_line_customer_user,access_account_move_line,account.model_account_move_line,rma.group_rma_customer_user,1,0,0,0
|
||||
access_account_move_line_supplier_user,access_account_move_line,account.model_account_move_line,rma.group_rma_supplier_user,1,0,0,0
|
||||
access_rma_refund_customer_user_item,rma.refund.customer.user,model_rma_refund,rma.group_rma_customer_user,1,1,1,1
|
||||
access_rma_refund_supplier_user_item,rma.refund.supplier.user,model_rma_refund,rma.group_rma_supplier_user,1,1,1,1
|
||||
access_rma_refund_item_customer_user_item,rma.refund.item.customer.user,model_rma_refund_item,rma.group_rma_customer_user,1,1,1,1
|
||||
access_rma_refund_item_supplier_user_item,rma.refund.item.supplier.user,model_rma_refund_item,rma.group_rma_supplier_user,1,1,1,1
|
||||
access_rma_add_account_move_customer_user_item,rma.add.account.move.customer.user,model_rma_add_account_move,rma.group_rma_customer_user,1,1,1,1
|
||||
access_rma_add_account_move_supplier_user_item,rma.add.account.move.supplier.user,model_rma_add_account_move,rma.group_rma_supplier_user,1,1,1,1
|
||||
|
||||
|
@@ -78,7 +78,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
||||
cls.invoices = cls.env["account.move"].create(
|
||||
[
|
||||
{
|
||||
"type": "out_invoice",
|
||||
"move_type": "out_invoice",
|
||||
"partner_id": customer1.id,
|
||||
"invoice_date": fields.Date.from_string("2016-01-01"),
|
||||
"currency_id": cls.currency_id.id,
|
||||
@@ -106,7 +106,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
||||
],
|
||||
},
|
||||
{
|
||||
"type": "in_invoice",
|
||||
"move_type": "in_invoice",
|
||||
"partner_id": supplier1.id,
|
||||
"invoice_date": fields.Date.from_string("2016-01-01"),
|
||||
"currency_id": cls.currency_id.id,
|
||||
|
||||
@@ -55,11 +55,10 @@
|
||||
<field
|
||||
name="add_rma_line_id"
|
||||
context="{'rma': True}"
|
||||
domain="[('type', '=', 'customer'),
|
||||
('partner_id', '=', partner_id)]"
|
||||
domain="[('type', '=', 'customer'),('partner_id', '=', partner_id)]"
|
||||
attrs="{'readonly': [('state','not in',['draft'])],
|
||||
'invisible': ['|', ('state', '=', 'paid'),
|
||||
('type', '=', 'in_invoice')]}"
|
||||
('move_type', '=', 'in_invoice')]}"
|
||||
class="oe_edit_only"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
name="account_move_line_id"
|
||||
options="{'no_create': True}"
|
||||
context="{'rma': True}"
|
||||
domain="['|',
|
||||
domain="[('move_id.move_type', 'not in', ['entry','out_invoice','out_refund']), '|',
|
||||
('move_id.partner_id', '=', partner_id),
|
||||
('move_id.partner_id', 'child_of', partner_id)]"
|
||||
/>
|
||||
@@ -86,7 +86,7 @@
|
||||
name="account_move_line_id"
|
||||
options="{'no_create': True}"
|
||||
context="{'rma': True}"
|
||||
domain="['|',
|
||||
domain="[('move_id.move_type', '!=', 'entry'), '|',
|
||||
('move_id.partner_id', '=', partner_id),
|
||||
('move_id.partner_id', 'child_of', partner_id)]"
|
||||
/>
|
||||
|
||||
@@ -7,17 +7,12 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select Invoice from customer">
|
||||
<group>
|
||||
<field
|
||||
name="partner_id"
|
||||
domain="[('customer','=',True)]"
|
||||
string="Customer"
|
||||
/>
|
||||
<field name="partner_id" />
|
||||
</group>
|
||||
<separator string="Select Invoices lines to add" />
|
||||
<field
|
||||
name="line_ids"
|
||||
domain="[('move_id.partner_id', '=', partner_id),
|
||||
('move_id.type', '=', 'out_invoice')]"
|
||||
domain="[('move_id.partner_id', '=', partner_id)]"
|
||||
>
|
||||
<tree string="Invoice Lines">
|
||||
<field name="move_id" />
|
||||
@@ -57,17 +52,12 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select Invoice from supplier">
|
||||
<group>
|
||||
<field
|
||||
name="partner_id"
|
||||
domain="[('supplier','=',True)]"
|
||||
string="Supplier"
|
||||
/>
|
||||
<field name="partner_id" />
|
||||
</group>
|
||||
<separator string="Select Invoices lines to add" />
|
||||
<field
|
||||
name="line_ids"
|
||||
domain="[('move_id.partner_id', '=', partner_id),
|
||||
('move_id.type', '=', 'in_invoice')]"
|
||||
domain="[('move_id.partner_id', '=', partner_id)]"
|
||||
>
|
||||
<tree string="Invoice Lines">
|
||||
<field name="move_id" />
|
||||
|
||||
@@ -70,7 +70,10 @@ class RmaRefund(models.TransientModel):
|
||||
string="Reason", required=True, default=lambda self: self._get_reason()
|
||||
)
|
||||
item_ids = fields.One2many(
|
||||
comodel_name="rma.refund.item", inverse_name="wiz_id", string="Items"
|
||||
comodel_name="rma.refund.item",
|
||||
inverse_name="wiz_id",
|
||||
string="Items",
|
||||
required=True,
|
||||
)
|
||||
|
||||
def compute_refund(self):
|
||||
@@ -92,7 +95,7 @@ class RmaRefund(models.TransientModel):
|
||||
new_invoice = self.compute_refund()
|
||||
action = (
|
||||
"action_move_out_refund_type"
|
||||
if (new_invoice.type in ["out_refund", "out_invoice"])
|
||||
if (new_invoice.move_type in ["out_refund", "out_invoice"])
|
||||
else "action_move_in_refund_type"
|
||||
)
|
||||
result = self.env.ref("account.%s" % action).read()[0]
|
||||
@@ -103,7 +106,7 @@ class RmaRefund(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def prepare_refund_line(self, item):
|
||||
accounts = item.product_id.product_tmpl_id._get_product_accounts()
|
||||
accounts = item.product.product_tmpl_id._get_product_accounts()
|
||||
if item.line_id.type == "customer":
|
||||
account = accounts["stock_output"]
|
||||
else:
|
||||
@@ -116,7 +119,7 @@ class RmaRefund(models.TransientModel):
|
||||
"account_id": account.id,
|
||||
"price_unit": item.line_id.price_unit,
|
||||
"product_uom_id": item.line_id.uom_id.id,
|
||||
"product_id": item.product_id.id,
|
||||
"product_id": item.product.id,
|
||||
"rma_line_id": item.line_id.id,
|
||||
"quantity": item.qty_to_refund,
|
||||
}
|
||||
@@ -135,10 +138,10 @@ class RmaRefund(models.TransientModel):
|
||||
)
|
||||
values = {
|
||||
"name": rma_line.rma_id.name or rma_line.name,
|
||||
"invoice_payment_ref": rma_line.rma_id.name or rma_line.name,
|
||||
"payment_reference": rma_line.rma_id.name or rma_line.name,
|
||||
"invoice_origin": rma_line.rma_id.name or rma_line.name,
|
||||
"ref": False,
|
||||
"type": "in_refund" if rma_line.type == "supplier" else "out_refund",
|
||||
"move_type": "in_refund" if rma_line.type == "supplier" else "out_refund",
|
||||
"journal_id": journal.id,
|
||||
"fiscal_position_id": rma_line.partner_id.property_account_position_id.id,
|
||||
"state": "draft",
|
||||
@@ -163,9 +166,9 @@ class RmaRefund(models.TransientModel):
|
||||
if team_id:
|
||||
values["team_id"] = team_id.id
|
||||
if rma_line.type == "customer":
|
||||
values["type"] = "out_refund"
|
||||
values["move_type"] = "out_refund"
|
||||
else:
|
||||
values["type"] = "in_refund"
|
||||
values["move_type"] = "in_refund"
|
||||
return values
|
||||
|
||||
@api.constrains("item_ids")
|
||||
@@ -187,20 +190,16 @@ class RmaRefundItem(models.TransientModel):
|
||||
"rma.order.line",
|
||||
string="RMA order Line",
|
||||
required=True,
|
||||
readonly=True,
|
||||
ondelete="cascade",
|
||||
)
|
||||
rma_id = fields.Many2one(
|
||||
"rma.order", related="line_id.rma_id", string="RMA", readonly=True
|
||||
)
|
||||
rma_id = fields.Many2one("rma.order", related="line_id.rma_id", string="RMA")
|
||||
product_id = fields.Many2one("product.product", string="Product (Technical)")
|
||||
product = fields.Many2one("product.product", string="Product", readonly=True)
|
||||
product = fields.Many2one("product.product", string="Product", required=True)
|
||||
name = fields.Char(string="Description", required=True)
|
||||
product_qty = fields.Float(
|
||||
string="Quantity Ordered",
|
||||
copy=False,
|
||||
digits="Product Unit of Measure",
|
||||
readonly=True,
|
||||
)
|
||||
invoice_address_id = fields.Many2one(
|
||||
comodel_name="res.partner", string="Invoice Address"
|
||||
@@ -208,7 +207,7 @@ class RmaRefundItem(models.TransientModel):
|
||||
qty_to_refund = fields.Float(
|
||||
string="Quantity To Refund", digits="Product Unit of Measure"
|
||||
)
|
||||
uom_id = fields.Many2one("uom.uom", string="Unit of Measure", readonly=True)
|
||||
uom_id = fields.Many2one("uom.uom", string="Unit of Measure")
|
||||
refund_policy = fields.Selection(
|
||||
selection=[
|
||||
("no", "Not required"),
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
</group>
|
||||
<field name="item_ids">
|
||||
<tree string="RMA Lines" editable="bottom">
|
||||
<field name="rma_id" invisible="1" />
|
||||
<field name="product_id" invisible="1" />
|
||||
<field name="rma_id" invisible="1" readonly="1" />
|
||||
<field name="product_id" invisible="1" readonly="1" />
|
||||
<field name="product" />
|
||||
<field name="name" />
|
||||
<field name="product_qty" />
|
||||
<field name="uom_id" groups="uom.group_uom" />
|
||||
<field name="line_id" />
|
||||
<field name="product_qty" readonly="1" />
|
||||
<field name="uom_id" groups="uom.group_uom" readonly="1" />
|
||||
<field name="qty_to_refund" readonly="0" />
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user