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",
|
||||
"version": "12.0.1.0.0",
|
||||
"category": "Manufacturing",
|
||||
"website": "https://github.com/oca/manufacture",
|
||||
"author": "AvanzOSC, "
|
||||
"Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"author": "AvanzOSC, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
'installable': True,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"mrp",
|
||||
"sale_stock",
|
||||
@@ -21,5 +19,5 @@
|
||||
"data": [
|
||||
"views/mrp_production.xml",
|
||||
"views/mrp_workorder.xml",
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
@@ -10,14 +10,22 @@ class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
source_procurement_group_id = fields.Many2one(
|
||||
comodel_name='procurement.group', readonly=True,
|
||||
comodel_name="procurement.group",
|
||||
readonly=True,
|
||||
)
|
||||
sale_id = fields.Many2one(
|
||||
comodel_name='sale.order', string='Sale order', readonly=True,
|
||||
store=True, related='source_procurement_group_id.sale_id')
|
||||
comodel_name="sale.order",
|
||||
string="Sale order",
|
||||
readonly=True,
|
||||
store=True,
|
||||
related="source_procurement_group_id.sale_id",
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner', related='sale_id.partner_id',
|
||||
string='Customer', store=True)
|
||||
comodel_name="res.partner",
|
||||
related="sale_id.partner_id",
|
||||
string="Customer",
|
||||
store=True,
|
||||
)
|
||||
commitment_date = fields.Datetime(
|
||||
related='sale_id.commitment_date', string='Commitment Date',
|
||||
store=True)
|
||||
related="sale_id.commitment_date", string="Commitment Date", store=True
|
||||
)
|
||||
|
||||
@@ -8,10 +8,15 @@ from odoo import fields, models
|
||||
class MrpWorkorder(models.Model):
|
||||
_inherit = "mrp.workorder"
|
||||
|
||||
sale_id = fields.Many2one(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)
|
||||
commitment_date = fields.Datetime(related='sale_id.commitment_date',
|
||||
string='Commitment Date', store=True,
|
||||
readonly=True)
|
||||
sale_id = fields.Many2one(
|
||||
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
|
||||
)
|
||||
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):
|
||||
_inherit = 'stock.rule'
|
||||
_inherit = "stock.rule"
|
||||
|
||||
def _prepare_mo_vals(self, product_id, product_qty, product_uom,
|
||||
location_id, name, origin, values, bom):
|
||||
def _prepare_mo_vals(
|
||||
self,
|
||||
product_id,
|
||||
product_qty,
|
||||
product_uom,
|
||||
location_id,
|
||||
name,
|
||||
origin,
|
||||
values,
|
||||
bom,
|
||||
):
|
||||
res = super()._prepare_mo_vals(
|
||||
product_id, product_qty, product_uom, location_id, name,
|
||||
origin, values, bom
|
||||
product_id, product_qty, product_uom, location_id, name, 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
|
||||
|
||||
@@ -8,28 +8,38 @@ class TestMrpSaleInfo(common.SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.product = cls.env["product.product"].create({
|
||||
cls.product = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Test mrp_sale_info product",
|
||||
"type": "product",
|
||||
"route_ids": [
|
||||
(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({
|
||||
}
|
||||
)
|
||||
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.sale_order = cls.env["sale.order"].create({
|
||||
cls.sale_order = cls.env["sale.order"].create(
|
||||
{
|
||||
"partner_id": cls.partner.id,
|
||||
"order_line": [
|
||||
(0, 0, {
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"product_id": cls.product.id,
|
||||
"product_uom_qty": 1,
|
||||
"price_unit": 1,
|
||||
}),
|
||||
]
|
||||
})
|
||||
},
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
def test_mrp_sale_info(self):
|
||||
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>
|
||||
<record id="mrp_production_form_view" model="ir.ui.view">
|
||||
<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="arch" type="xml">
|
||||
<field name="availability" position="after">
|
||||
<field name="sale_id"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="commitment_date"/>
|
||||
<field name="sale_id" />
|
||||
<field name="partner_id" />
|
||||
<field name="commitment_date" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -16,12 +16,12 @@
|
||||
<record id="mrp_production_tree_view" model="ir.ui.view">
|
||||
<field name="name">MRP Production Tree with Sale Order</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="date_planned_start" position="after">
|
||||
<field name="sale_id"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="commitment_date"/>
|
||||
<field name="sale_id" />
|
||||
<field name="partner_id" />
|
||||
<field name="commitment_date" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<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="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="date_planned_start" position="after">
|
||||
<field name="sale_id"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="commitment_date"/>
|
||||
<field name="sale_id" />
|
||||
<field name="partner_id" />
|
||||
<field name="commitment_date" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -16,12 +16,12 @@
|
||||
<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="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="production_id" position="after">
|
||||
<field name="sale_id"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="commitment_date"/>
|
||||
<field name="sale_id" />
|
||||
<field name="partner_id" />
|
||||
<field name="commitment_date" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user