mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_sale_info: black, isort, prettier
This commit is contained in:
@@ -7,13 +7,11 @@
|
|||||||
"summary": "Adds sale information to Manufacturing models",
|
"summary": "Adds sale information to Manufacturing models",
|
||||||
"version": "12.0.1.0.0",
|
"version": "12.0.1.0.0",
|
||||||
"category": "Manufacturing",
|
"category": "Manufacturing",
|
||||||
"website": "https://github.com/oca/manufacture",
|
"website": "https://github.com/OCA/manufacture",
|
||||||
"author": "AvanzOSC, "
|
"author": "AvanzOSC, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||||
"Tecnativa, "
|
|
||||||
"Odoo Community Association (OCA)",
|
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"application": False,
|
"application": False,
|
||||||
'installable': True,
|
"installable": True,
|
||||||
"depends": [
|
"depends": [
|
||||||
"mrp",
|
"mrp",
|
||||||
"sale_stock",
|
"sale_stock",
|
||||||
@@ -21,5 +19,5 @@
|
|||||||
"data": [
|
"data": [
|
||||||
"views/mrp_production.xml",
|
"views/mrp_production.xml",
|
||||||
"views/mrp_workorder.xml",
|
"views/mrp_workorder.xml",
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,22 @@ class MrpProduction(models.Model):
|
|||||||
_inherit = "mrp.production"
|
_inherit = "mrp.production"
|
||||||
|
|
||||||
source_procurement_group_id = fields.Many2one(
|
source_procurement_group_id = fields.Many2one(
|
||||||
comodel_name='procurement.group', readonly=True,
|
comodel_name="procurement.group",
|
||||||
|
readonly=True,
|
||||||
)
|
)
|
||||||
sale_id = fields.Many2one(
|
sale_id = fields.Many2one(
|
||||||
comodel_name='sale.order', string='Sale order', readonly=True,
|
comodel_name="sale.order",
|
||||||
store=True, related='source_procurement_group_id.sale_id')
|
string="Sale order",
|
||||||
|
readonly=True,
|
||||||
|
store=True,
|
||||||
|
related="source_procurement_group_id.sale_id",
|
||||||
|
)
|
||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
comodel_name='res.partner', related='sale_id.partner_id',
|
comodel_name="res.partner",
|
||||||
string='Customer', store=True)
|
related="sale_id.partner_id",
|
||||||
|
string="Customer",
|
||||||
|
store=True,
|
||||||
|
)
|
||||||
commitment_date = fields.Datetime(
|
commitment_date = fields.Datetime(
|
||||||
related='sale_id.commitment_date', string='Commitment Date',
|
related="sale_id.commitment_date", string="Commitment Date", store=True
|
||||||
store=True)
|
)
|
||||||
|
|||||||
@@ -8,10 +8,15 @@ from odoo import fields, models
|
|||||||
class MrpWorkorder(models.Model):
|
class MrpWorkorder(models.Model):
|
||||||
_inherit = "mrp.workorder"
|
_inherit = "mrp.workorder"
|
||||||
|
|
||||||
sale_id = fields.Many2one(related='production_id.sale_id',
|
sale_id = fields.Many2one(
|
||||||
string='Sale order', readonly=True, store=True)
|
related="production_id.sale_id", string="Sale order", readonly=True, store=True
|
||||||
partner_id = fields.Many2one(related='sale_id.partner_id', readonly=True,
|
)
|
||||||
string='Customer', store=True)
|
partner_id = fields.Many2one(
|
||||||
commitment_date = fields.Datetime(related='sale_id.commitment_date',
|
related="sale_id.partner_id", readonly=True, string="Customer", store=True
|
||||||
string='Commitment Date', store=True,
|
)
|
||||||
readonly=True)
|
commitment_date = fields.Datetime(
|
||||||
|
related="sale_id.commitment_date",
|
||||||
|
string="Commitment Date",
|
||||||
|
store=True,
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
|||||||
@@ -6,14 +6,23 @@ from odoo import models
|
|||||||
|
|
||||||
|
|
||||||
class StockRule(models.Model):
|
class StockRule(models.Model):
|
||||||
_inherit = 'stock.rule'
|
_inherit = "stock.rule"
|
||||||
|
|
||||||
def _prepare_mo_vals(self, product_id, product_qty, product_uom,
|
def _prepare_mo_vals(
|
||||||
location_id, name, origin, values, bom):
|
self,
|
||||||
|
product_id,
|
||||||
|
product_qty,
|
||||||
|
product_uom,
|
||||||
|
location_id,
|
||||||
|
name,
|
||||||
|
origin,
|
||||||
|
values,
|
||||||
|
bom,
|
||||||
|
):
|
||||||
res = super()._prepare_mo_vals(
|
res = super()._prepare_mo_vals(
|
||||||
product_id, product_qty, product_uom, location_id, name,
|
product_id, product_qty, product_uom, location_id, name, origin, values, bom
|
||||||
origin, values, bom
|
)
|
||||||
|
res["source_procurement_group_id"] = (
|
||||||
|
values.get("group_id").id if values.get("group_id", False) else False
|
||||||
)
|
)
|
||||||
res["source_procurement_group_id"] = values.get(
|
|
||||||
"group_id").id if values.get('group_id', False) else False
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -8,28 +8,38 @@ class TestMrpSaleInfo(common.SavepointCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
cls.product = cls.env["product.product"].create({
|
cls.product = cls.env["product.product"].create(
|
||||||
"name": "Test mrp_sale_info product",
|
{
|
||||||
"type": "product",
|
"name": "Test mrp_sale_info product",
|
||||||
"route_ids": [
|
"type": "product",
|
||||||
(4, cls.env.ref("mrp.route_warehouse0_manufacture").id),
|
"route_ids": [
|
||||||
(4, cls.env.ref("stock.route_warehouse0_mto").id),
|
(4, cls.env.ref("mrp.route_warehouse0_manufacture").id),
|
||||||
],
|
(4, cls.env.ref("stock.route_warehouse0_mto").id),
|
||||||
})
|
],
|
||||||
cls.bom = cls.env["mrp.bom"].create({
|
}
|
||||||
"product_tmpl_id": cls.product.product_tmpl_id.id,
|
)
|
||||||
})
|
cls.bom = cls.env["mrp.bom"].create(
|
||||||
|
{
|
||||||
|
"product_tmpl_id": cls.product.product_tmpl_id.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
|
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
|
||||||
cls.sale_order = cls.env["sale.order"].create({
|
cls.sale_order = cls.env["sale.order"].create(
|
||||||
"partner_id": cls.partner.id,
|
{
|
||||||
"order_line": [
|
"partner_id": cls.partner.id,
|
||||||
(0, 0, {
|
"order_line": [
|
||||||
"product_id": cls.product.id,
|
(
|
||||||
"product_uom_qty": 1,
|
0,
|
||||||
"price_unit": 1,
|
0,
|
||||||
}),
|
{
|
||||||
]
|
"product_id": cls.product.id,
|
||||||
})
|
"product_uom_qty": 1,
|
||||||
|
"price_unit": 1,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def test_mrp_sale_info(self):
|
def test_mrp_sale_info(self):
|
||||||
prev_productions = self.env["mrp.production"].search([])
|
prev_productions = self.env["mrp.production"].search([])
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="mrp_production_form_view" model="ir.ui.view">
|
<record id="mrp_production_form_view" model="ir.ui.view">
|
||||||
<field name="name">MRP Production Form with Sale Order</field>
|
<field name="name">MRP Production Form with Sale Order</field>
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
|
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="availability" position="after">
|
<field name="availability" position="after">
|
||||||
<field name="sale_id"/>
|
<field name="sale_id" />
|
||||||
<field name="partner_id"/>
|
<field name="partner_id" />
|
||||||
<field name="commitment_date"/>
|
<field name="commitment_date" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
<record id="mrp_production_tree_view" model="ir.ui.view">
|
<record id="mrp_production_tree_view" model="ir.ui.view">
|
||||||
<field name="name">MRP Production Tree with Sale Order</field>
|
<field name="name">MRP Production Tree with Sale Order</field>
|
||||||
<field name="model">mrp.production</field>
|
<field name="model">mrp.production</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
|
<field name="inherit_id" ref="mrp.mrp_production_tree_view" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="date_planned_start" position="after">
|
<field name="date_planned_start" position="after">
|
||||||
<field name="sale_id"/>
|
<field name="sale_id" />
|
||||||
<field name="partner_id"/>
|
<field name="partner_id" />
|
||||||
<field name="commitment_date"/>
|
<field name="commitment_date" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="mrp_production_workorder_tree_view_inherit" model="ir.ui.view">
|
<record id="mrp_production_workorder_tree_view_inherit" model="ir.ui.view">
|
||||||
<field name="name">MRP Work Order Tree with Sale Order</field>
|
<field name="name">MRP Work Order Tree with Sale Order</field>
|
||||||
<field name="model">mrp.workorder</field>
|
<field name="model">mrp.workorder</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view_inherit"/>
|
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view_inherit" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="date_planned_start" position="after">
|
<field name="date_planned_start" position="after">
|
||||||
<field name="sale_id"/>
|
<field name="sale_id" />
|
||||||
<field name="partner_id"/>
|
<field name="partner_id" />
|
||||||
<field name="commitment_date"/>
|
<field name="commitment_date" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
<record id="mrp_production_workorder_form_view_inherit" model="ir.ui.view">
|
<record id="mrp_production_workorder_form_view_inherit" model="ir.ui.view">
|
||||||
<field name="name">MRP Work Order Form with Sale Order</field>
|
<field name="name">MRP Work Order Form with Sale Order</field>
|
||||||
<field name="model">mrp.workorder</field>
|
<field name="model">mrp.workorder</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="production_id" position="after">
|
<field name="production_id" position="after">
|
||||||
<field name="sale_id"/>
|
<field name="sale_id" />
|
||||||
<field name="partner_id"/>
|
<field name="partner_id" />
|
||||||
<field name="commitment_date"/>
|
<field name="commitment_date" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user