mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] rma_delivery: add default in carrier
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "RMA delivery integration",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.1.1.0",
|
||||
"license": "LGPL-3",
|
||||
"category": "RMA",
|
||||
"summary": "RMA default carrier on operation" "in odoo",
|
||||
|
||||
20
rma_delivery/migrations/14.0.1.1.0/pre-migration.py
Normal file
20
rma_delivery/migrations/14.0.1.1.0/pre-migration.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright 2022 ForgeFlow S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openupgradelib import openupgrade
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
if openupgrade.column_exists(env.cr, "delivery_carrier", "default_carrier_id"):
|
||||
openupgrade.rename_fields(
|
||||
env,
|
||||
[
|
||||
(
|
||||
"rma.operation",
|
||||
"rma_operation",
|
||||
"default_carrier_id",
|
||||
"default_carrier_out_id",
|
||||
)
|
||||
],
|
||||
)
|
||||
@@ -8,6 +8,16 @@ class RmaOperation(models.Model):
|
||||
|
||||
_inherit = "rma.operation"
|
||||
|
||||
default_carrier_id = fields.Many2one(
|
||||
comodel_name="delivery.carrier", string="Default carrier", required=False
|
||||
default_carrier_in_id = fields.Many2one(
|
||||
comodel_name="delivery.carrier",
|
||||
string="Default Recepit carrier",
|
||||
required=False,
|
||||
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",
|
||||
)
|
||||
|
||||
default_carrier_out_id = fields.Many2one(
|
||||
comodel_name="delivery.carrier",
|
||||
string="Default Delivery carrier",
|
||||
required=False,
|
||||
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestRmaDelivery(TestRma):
|
||||
)
|
||||
cls.rma_cust_replace_op_id.write(
|
||||
{
|
||||
"default_carrier_id": cls.carrier_id.id,
|
||||
"default_carrier_out_id": cls.carrier_id.id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
<field name="model">rma.operation</field>
|
||||
<field name="inherit_id" ref="rma.rma_operation_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='receipt_policy']" position="after">
|
||||
<field name="default_carrier_in_id" options="{'no_create': True}" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='delivery_policy']" position="after">
|
||||
<field name="default_carrier_id" options="{'no_create': True}" />
|
||||
<field name="default_carrier_out_id" options="{'no_create': True}" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -11,8 +11,13 @@ class RmaMakePicking(models.TransientModel):
|
||||
def _create_picking(self):
|
||||
res = super()._create_picking()
|
||||
for line in self.mapped("item_ids.line_id").filtered(
|
||||
lambda x: x.operation_id.default_carrier_id
|
||||
lambda x: x.operation_id.default_carrier_out_id
|
||||
):
|
||||
pickings = line._get_out_pickings().filtered(lambda x: not x.carrier_id)
|
||||
pickings.write({"carrier_id": line.operation_id.default_carrier_id.id})
|
||||
pickings.write({"carrier_id": line.operation_id.default_carrier_out_id.id})
|
||||
for line in self.mapped("item_ids.line_id").filtered(
|
||||
lambda x: x.operation_id.default_carrier_in_id
|
||||
):
|
||||
pickings = line._get_in_pickings().filtered(lambda x: not x.carrier_id)
|
||||
pickings.write({"carrier_id": line.operation_id.default_carrier_in_id.id})
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user