Skip to content

Commit de43c02

Browse files
committed
[IMP] mrp_production_stencil_product: pre-commit stuff
1 parent dfc2235 commit de43c02

14 files changed

+116
-56
lines changed

mrp_production_stencil_product/models/mrp_bom.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class MrpBom(models.Model):
77
_inherit = "mrp.bom"
88

99
stencil_product_ids = fields.One2many(
10-
string="Stencil products", comodel_name="mrp.bom.stencil.product",
11-
inverse_name="bom_id", copy=False
10+
string="Stencil products",
11+
comodel_name="mrp.bom.stencil.product",
12+
inverse_name="bom_id",
13+
copy=False,
1214
)

mrp_production_stencil_product/models/mrp_bom_stencil_product.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ class MrpBomStencilProduct(models.Model):
77
_name = "mrp.bom.stencil.product"
88
_description = "Stentil products in BoMs"
99

10-
bom_id = fields.Many2one(
11-
string="BoM", comodel_name="mrp.bom", copy=False
12-
)
10+
bom_id = fields.Many2one(string="BoM", comodel_name="mrp.bom", copy=False)
1311
product_id = fields.Many2one(
1412
string="Product", comodel_name="product.product", copy=False
1513
)

mrp_production_stencil_product/models/mrp_production.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ class MrpProduction(models.Model):
77
_inherit = "mrp.production"
88

99
stencil_product_ids = fields.Many2many(
10-
string="Stencil products", comodel_name="mrp.bom.stencil.product",
11-
compute='_compute_stencil_product_ids', store=True, readonly=True,
10+
string="Stencil products",
11+
comodel_name="mrp.bom.stencil.product",
12+
compute="_compute_stencil_product_ids",
13+
store=True,
14+
readonly=True,
1215
copy=False,
1316
)
1417

mrp_production_stencil_product/models/mrp_workorder.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ class MrpWorkorder(models.Model):
77
_inherit = "mrp.workorder"
88

99
stencil_product_ids = fields.Many2many(
10-
string="Stencil products", comodel_name="mrp.bom.stencil.product",
11-
compute='_compute_stencil_product_ids', store=True, readonly=True,
10+
string="Stencil products",
11+
comodel_name="mrp.bom.stencil.product",
12+
compute="_compute_stencil_product_ids",
13+
store=True,
14+
readonly=True,
1215
copy=False,
1316
)
1417

15-
@api.depends("production_id", "production_id.move_raw_ids",
16-
"production_id.move_raw_ids.workorder_id",
17-
"production_id.move_raw_ids.bom_line_id")
18+
@api.depends(
19+
"production_id",
20+
"production_id.move_raw_ids",
21+
"production_id.move_raw_ids.workorder_id",
22+
"production_id.move_raw_ids.bom_line_id",
23+
)
1824
def _compute_stencil_product_ids(self):
1925
for workorder in self:
2026
stencil_product_ids = []
21-
if (workorder.production_id and
22-
workorder.production_id.move_raw_ids):
27+
if workorder.production_id and workorder.production_id.move_raw_ids:
2328
moves = workorder.production_id.move_raw_ids.filtered(
24-
lambda x: x.workorder_id.id == workorder.id)
29+
lambda x: x.workorder_id.id == workorder.id
30+
)
2531
boms = moves.bom_line_id.mapped("bom_id")
2632
for bom in boms:
2733
for stencil_product in bom.stencil_product_ids:

mrp_production_stencil_product/models/product_category.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class ProductCategory(models.Model):
77
_inherit = "product.category"
88

99
stencil_category = fields.Boolean(
10-
string="Stencil category", comodel_name="product.category",
11-
default=False, copy=False,
10+
string="Stencil category",
11+
comodel_name="product.category",
12+
default=False,
13+
copy=False,
1214
)

mrp_production_stencil_product/models/product_template.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class ProductTemplate(models.Model):
77
_inherit = "product.template"
88

99
stencil_category = fields.Boolean(
10-
string="Stencil category", related="categ_id.stencil_category",
11-
store= True, copy=False,
10+
string="Stencil category",
11+
related="categ_id.stencil_category",
12+
store=True,
13+
copy=False,
1214
)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
22
access_mrp_bom_stencil_product_user,mrp.bom.stencil.product.user,model_mrp_bom_stencil_product,mrp.group_mrp_user,1,0,0,0
33
access_mrp_bom_stencil_product_manager,mrp.bom.stencil.product.manager,model_mrp_bom_stencil_product,mrp.group_mrp_manager,1,1,1,1
4-

mrp_production_stencil_product/views/mrp_bom_views.xml

+12-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@
88
<page name="stencil-products" string="Stencil products">
99
<field name="stencil_product_ids" nolabel="1">
1010
<tree string="Stencil products" editable="bottom">
11-
<field name="bom_id" invisible="1"/>
12-
<field name="product_id"
13-
domain="[('stencil_category', '=', True)]"/>
14-
<field name="location_id"/>
15-
<field name="product_uom_qty"/>
16-
<field name="product_uom_id"/>
11+
<field name="bom_id" invisible="1" />
12+
<field
13+
name="product_id"
14+
domain="[('stencil_category', '=', True)]"
15+
/>
16+
<field name="location_id" />
17+
<field name="product_uom_qty" />
18+
<field name="product_uom_id" />
1719
</tree>
1820
</field>
1921
</page>
2022
</page>
21-
<xpath expr="//field[@name='bom_line_ids']/tree/field[@name='product_id']" position="attributes">
23+
<xpath
24+
expr="//field[@name='bom_line_ids']/tree/field[@name='product_id']"
25+
position="attributes"
26+
>
2227
<attribute name="domain">[('stencil_category', '=', False)]</attribute>
2328
</xpath>
2429
</field>

mrp_production_stencil_product/views/mrp_production_views.xml

+12-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@
88
<page name="stencil-products" string="Stencil products">
99
<field name="stencil_product_ids" nolabel="1">
1010
<tree string="Stencil products">
11-
<field name="bom_id" invisible="1"/>
12-
<field name="product_id"
13-
domain="[('stencil_category', '=', True)]"/>
14-
<field name="location_id"/>
15-
<field name="product_uom_qty"/>
16-
<field name="product_uom_id"/>
11+
<field name="bom_id" invisible="1" />
12+
<field
13+
name="product_id"
14+
domain="[('stencil_category', '=', True)]"
15+
/>
16+
<field name="location_id" />
17+
<field name="product_uom_qty" />
18+
<field name="product_uom_id" />
1719
</tree>
1820
</field>
1921
</page>
2022
</page>
21-
<xpath expr="//field[@name='move_raw_ids']/tree/field[@name='product_id']" position="attributes">
23+
<xpath
24+
expr="//field[@name='move_raw_ids']/tree/field[@name='product_id']"
25+
position="attributes"
26+
>
2227
<attribute name="domain">[('stencil_category', '=', False)]</attribute>
2328
</xpath>
2429
</field>

mrp_production_stencil_product/views/mrp_workorder_views.xml

+19-7
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22
<odoo>
33
<record id="mrp_production_workorder_tree_editable_view" model="ir.ui.view">
44
<field name="model">mrp.workorder</field>
5-
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view" />
5+
<field
6+
name="inherit_id"
7+
ref="mrp.mrp_production_workorder_tree_editable_view"
8+
/>
69
<field name="arch" type="xml">
710
<field name="qty_remaining" position="after">
8-
<field name="stencil_product_ids" widget="many2many_tags"/>
11+
<field name="stencil_product_ids" widget="many2many_tags" />
912
</field>
1013
</field>
1114
</record>
1215

1316
<record id="view_mrp_production_workorder_form_view_filter" model="ir.ui.view">
1417
<field name="model">mrp.workorder</field>
15-
<field name="inherit_id" ref="mrp.view_mrp_production_workorder_form_view_filter" />
18+
<field
19+
name="inherit_id"
20+
ref="mrp.view_mrp_production_workorder_form_view_filter"
21+
/>
1622
<field name="arch" type="xml">
1723
<field name="product_id" position="after">
18-
<field name="stencil_product_ids" string="Stencil product"
19-
filter_domain="[('stencil_product_ids.product_id', 'ilike', self)]"/>
24+
<field
25+
name="stencil_product_ids"
26+
string="Stencil product"
27+
filter_domain="[('stencil_product_ids.product_id', 'ilike', self)]"
28+
/>
2029
</field>
2130
</field>
2231
</record>
@@ -26,8 +35,11 @@
2635
<field name="inherit_id" ref="mrp.view_mrp_production_work_order_search" />
2736
<field name="arch" type="xml">
2837
<field name="product_id" position="after">
29-
<field name="stencil_product_ids" string="Stencil product"
30-
filter_domain="[('stencil_product_ids.product_id', 'ilike', self)]"/>
38+
<field
39+
name="stencil_product_ids"
40+
string="Stencil product"
41+
filter_domain="[('stencil_product_ids.product_id', 'ilike', self)]"
42+
/>
3143
</field>
3244
</field>
3345
</record>

mrp_production_stencil_product/views/product_category_views.xml

+18-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<group name="first" col="2" position="after">
88
<group name="stencil" col="2">
99
<separator string="Stencil" />
10-
<field name="stencil_category"/>
10+
<field name="stencil_category" />
1111
</group>
1212
</group>
1313
</field>
@@ -18,7 +18,7 @@
1818
<field name="inherit_id" ref="product.product_category_list_view" />
1919
<field name="arch" type="xml">
2020
<field name="display_name" position="after">
21-
<field name="stencil_category" optional="show"/>
21+
<field name="stencil_category" optional="show" />
2222
</field>
2323
</field>
2424
</record>
@@ -28,13 +28,23 @@
2828
<field name="inherit_id" ref="product.product_category_search_view" />
2929
<field name="arch" type="xml">
3030
<field name="parent_id" position="after">
31-
<filter string="Stencil category" domain="[('stencil_category', '=', True)]"
32-
name="filter-is_stencil_category"/>
33-
<filter string="NO Stencil category" domain="[('stencil_category', '=', False)]"
34-
name="filter-is_not_stencil_category"/>
31+
<filter
32+
string="Stencil category"
33+
domain="[('stencil_category', '=', True)]"
34+
name="filter-is_stencil_category"
35+
/>
36+
<filter
37+
string="NO Stencil category"
38+
domain="[('stencil_category', '=', False)]"
39+
name="filter-is_not_stencil_category"
40+
/>
3541
<group expand="0" string="Group By">
36-
<filter string="Stencil category" name="filter-stencil_category" domain="[]"
37-
context="{'group_by': 'stencil_category'}"/>
42+
<filter
43+
string="Stencil category"
44+
name="filter-stencil_category"
45+
domain="[]"
46+
context="{'group_by': 'stencil_category'}"
47+
/>
3848
</group>
3949
</field>
4050
</field>

mrp_production_stencil_product/views/product_template_views.xml

+16-7
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,24 @@
2525
<field name="inherit_id" ref="product.product_template_search_view" />
2626
<field name="arch" type="xml">
2727
<filter name="consumable" position="after">
28-
<separator/>
29-
<filter string="Stencil category" name="filter-is_stencil"
30-
domain="[('stencil_category', '=', True)]"/>
31-
<filter string="NO Stencil category" name="filter-is_not_stencil"
32-
domain="[('stencil_category', '=', False)]"/>
28+
<separator />
29+
<filter
30+
string="Stencil category"
31+
name="filter-is_stencil"
32+
domain="[('stencil_category', '=', True)]"
33+
/>
34+
<filter
35+
string="NO Stencil category"
36+
name="filter-is_not_stencil"
37+
domain="[('stencil_category', '=', False)]"
38+
/>
3339
</filter>
3440
<filter name="categ_id" position="after">
35-
<filter string="Stencil Category" name="filter-stencil_category"
36-
context="{'group_by':'stencil_category'}"/>
41+
<filter
42+
string="Stencil Category"
43+
name="filter-stencil_category"
44+
context="{'group_by':'stencil_category'}"
45+
/>
3746
</filter>
3847
</field>
3948
</record>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../mrp_production_stencil_product
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)