[MIG] rma_sale: Migration to 13.0

This commit is contained in:
Ernesto Tejeda
2020-10-28 17:04:17 -04:00
committed by Chafique
parent 0cbca17df5
commit 4a9259b23b
9 changed files with 24 additions and 29 deletions

View File

@@ -14,13 +14,13 @@ Return Merchandise Authorization Management - Link with Sales
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github
:target: https://github.com/OCA/rma/tree/12.0/rma_sale :target: https://github.com/OCA/rma/tree/13.0/rma_sale
:alt: OCA/rma :alt: OCA/rma
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma_sale :target: https://translation.odoo-community.org/projects/rma-13-0/rma-13-0-rma_sale
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/145/12.0 :target: https://runbot.odoo-community.org/runbot/145/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -79,7 +79,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_sale%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_sale%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@@ -121,6 +121,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-ernestotejeda| |maintainer-ernestotejeda|
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/12.0/rma_sale>`_ project on GitHub. This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/13.0/rma_sale>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -3,14 +3,14 @@
{ {
"name": "Return Merchandise Authorization Management - Link with Sales", "name": "Return Merchandise Authorization Management - Link with Sales",
"summary": "Sale Order - Return Merchandise Authorization (RMA)", "summary": "Sale Order - Return Merchandise Authorization (RMA)",
"version": "12.0.1.5.2", "version": "13.0.1.0.0",
"development_status": "Beta", "development_status": "Production/Stable",
"category": "RMA", "category": "RMA",
"website": "https://github.com/OCA/rma", "website": "https://github.com/OCA/rma",
"author": "Tecnativa, Odoo Community Association (OCA)", "author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["ernestotejeda"], "maintainers": ["ernestotejeda"],
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["rma", "sale_stock",], "depends": ["rma", "sale_stock"],
"data": [ "data": [
"views/assets.xml", "views/assets.xml",
"views/report_rma.xml", "views/report_rma.xml",

View File

@@ -20,15 +20,15 @@ class Rma(models.Model):
allowed_picking_ids = fields.Many2many( allowed_picking_ids = fields.Many2many(
comodel_name="stock.picking", compute="_compute_allowed_picking_ids", comodel_name="stock.picking", compute="_compute_allowed_picking_ids",
) )
picking_id = fields.Many2one(domain="[('id', 'in', allowed_picking_ids)]",) picking_id = fields.Many2one(domain="[('id', 'in', allowed_picking_ids)]")
allowed_move_ids = fields.Many2many( allowed_move_ids = fields.Many2many(
comodel_name="sale.order.line", compute="_compute_allowed_move_ids", comodel_name="sale.order.line", compute="_compute_allowed_move_ids",
) )
move_id = fields.Many2one(domain="[('id', 'in', allowed_move_ids)]",) move_id = fields.Many2one(domain="[('id', 'in', allowed_move_ids)]")
allowed_product_ids = fields.Many2many( allowed_product_ids = fields.Many2many(
comodel_name="product.product", compute="_compute_allowed_product_ids", comodel_name="product.product", compute="_compute_allowed_product_ids",
) )
product_id = fields.Many2one(domain="[('id', 'in', allowed_product_ids)]",) product_id = fields.Many2one(domain="[('id', 'in', allowed_product_ids)]")
@api.depends("partner_id", "order_id") @api.depends("partner_id", "order_id")
def _compute_allowed_picking_ids(self): def _compute_allowed_picking_ids(self):
@@ -81,5 +81,5 @@ class Rma(models.Model):
"""Inject salesman from sales order (if any)""" """Inject salesman from sales order (if any)"""
res = super()._prepare_refund(invoice_form, origin) res = super()._prepare_refund(invoice_form, origin)
if self.order_id: if self.order_id:
invoice_form.user_id = self.order_id.user_id invoice_form.invoice_user_id = self.order_id.user_id
return res return res

View File

@@ -12,7 +12,7 @@ class SaleOrder(models.Model):
rma_ids = fields.One2many( rma_ids = fields.One2many(
comodel_name="rma", inverse_name="order_id", string="RMAs", copy=False, comodel_name="rma", inverse_name="order_id", string="RMAs", copy=False,
) )
rma_count = fields.Integer(string="RMA count", compute="_compute_rma_count",) rma_count = fields.Integer(string="RMA count", compute="_compute_rma_count")
def _compute_rma_count(self): def _compute_rma_count(self):
rma_data = self.env["rma"].read_group( rma_data = self.env["rma"].read_group(
@@ -48,7 +48,6 @@ class SaleOrder(models.Model):
return { return {
"name": _("Create RMA"), "name": _("Create RMA"),
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
"view_type": "form",
"view_mode": "form", "view_mode": "form",
"res_model": "sale.order.rma.wizard", "res_model": "sale.order.rma.wizard",
"res_id": wizard.id, "res_id": wizard.id,

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rma/tree/12.0/rma_sale"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma_sale"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rma/tree/13.0/rma_sale"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-13-0/rma-13-0-rma_sale"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to link a sales order to an RMA. <p>This module allows you to link a sales order to an RMA.
This can be done by creating an RMA from scratch and selecting the sales This can be done by creating an RMA from scratch and selecting the sales
order, creating one or more RMAs from a sales order form view or from a sales order, creating one or more RMAs from a sales order form view or from a sales
@@ -430,7 +430,7 @@ number greater than the order line product quantity.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma_sale%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma_sale%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -461,7 +461,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/ernestotejeda"><img alt="ernestotejeda" src="https://github.com/ernestotejeda.png?size=40px" /></a></p> <p><a class="reference external" href="https://github.com/ernestotejeda"><img alt="ernestotejeda" src="https://github.com/ernestotejeda.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/12.0/rma_sale">OCA/rma</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/13.0/rma_sale">OCA/rma</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -13,12 +13,12 @@ class TestRmaSale(SavepointCase):
cls.sale_order = cls.env["sale.order"] cls.sale_order = cls.env["sale.order"]
cls.product_1 = cls.product_product.create( cls.product_1 = cls.product_product.create(
{"name": "Product test 1", "type": "product",} {"name": "Product test 1", "type": "product"}
) )
cls.product_2 = cls.product_product.create( cls.product_2 = cls.product_product.create(
{"name": "Product test 2", "type": "product",} {"name": "Product test 2", "type": "product"}
) )
cls.partner = cls.res_partner.create({"name": "Partner test",}) cls.partner = cls.res_partner.create({"name": "Partner test"})
order_form = Form(cls.sale_order) order_form = Form(cls.sale_order)
order_form.partner_id = cls.partner order_form.partner_id = cls.partner
with order_form.order_line.new() as line_form: with order_form.order_line.new() as line_form:
@@ -41,6 +41,7 @@ class TestRmaSale(SavepointCase):
rma_form.order_id = self.sale_order rma_form.order_id = self.sale_order
rma_form.product_id = self.product_1 rma_form.product_id = self.product_1
rma_form.product_uom_qty = 5 rma_form.product_uom_qty = 5
rma_form.location_id = self.sale_order.warehouse_id.rma_loc_id
rma = rma_form.save() rma = rma_form.save()
rma.action_confirm() rma.action_confirm()
self.assertTrue(rma.reception_move_id) self.assertTrue(rma.reception_move_id)
@@ -69,7 +70,7 @@ class TestRmaSale(SavepointCase):
) )
# Refund the RMA # Refund the RMA
user = self.env["res.users"].create( user = self.env["res.users"].create(
{"login": "test_refund_with_so", "name": "Test",} {"login": "test_refund_with_so", "name": "Test"}
) )
order.user_id = user.id order.user_id = user.id
rma.action_confirm() rma.action_confirm()

View File

@@ -6,7 +6,7 @@
<field name="inherit_id" ref="sale.view_order_form" /> <field name="inherit_id" ref="sale.view_order_form" />
<field name="groups_id" eval="[(4, ref('rma.rma_group_user_own'))]" /> <field name="groups_id" eval="[(4, ref('rma.rma_group_user_own'))]" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<button name="action_done" position="after"> <button name="action_draft" position="after">
<button <button
name="action_create_rma" name="action_create_rma"
type="object" type="object"

View File

@@ -3,8 +3,6 @@
from odoo import _, api, fields, models from odoo import _, api, fields, models
from odoo.addons import decimal_precision as dp
class SaleOrderRmaWizard(models.TransientModel): class SaleOrderRmaWizard(models.TransientModel):
_name = "sale.order.rma.wizard" _name = "sale.order.rma.wizard"
@@ -71,7 +69,7 @@ class SaleOrderLineRmaWizard(models.TransientModel):
_name = "sale.order.line.rma.wizard" _name = "sale.order.line.rma.wizard"
_description = "Sale Order Line Rma Wizard" _description = "Sale Order Line Rma Wizard"
wizard_id = fields.Many2one(comodel_name="sale.order.rma.wizard", string="Wizard",) wizard_id = fields.Many2one(comodel_name="sale.order.rma.wizard", string="Wizard")
order_id = fields.Many2one( order_id = fields.Many2one(
comodel_name="sale.order", comodel_name="sale.order",
default=lambda self: self.env["sale.order"].browse( default=lambda self: self.env["sale.order"].browse(
@@ -91,9 +89,7 @@ class SaleOrderLineRmaWizard(models.TransientModel):
comodel_name="uom.category", related="product_id.uom_id.category_id", comodel_name="uom.category", related="product_id.uom_id.category_id",
) )
quantity = fields.Float( quantity = fields.Float(
string="Quantity", string="Quantity", digits="Product Unit of Measure", required=True,
digits=dp.get_precision("Product Unit of Measure"),
required=True,
) )
uom_id = fields.Many2one( uom_id = fields.Many2one(
comodel_name="uom.uom", comodel_name="uom.uom",

View File

@@ -3,7 +3,6 @@
<record id="sale_order_create_rma_action" model="ir.actions.act_window"> <record id="sale_order_create_rma_action" model="ir.actions.act_window">
<field name="name">Create RMAs</field> <field name="name">Create RMAs</field>
<field name="res_model">sale.order.rma.wizard</field> <field name="res_model">sale.order.rma.wizard</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>
</record> </record>