Skip to content

Commit 225e584

Browse files
committed
[FIX] Improve migration to 11.0
1 parent cc3ff4c commit 225e584

8 files changed

+111
-145
lines changed

stock_available/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Configuration
2020

2121
By default, this module computes the stock available to promise as the virtual
2222
stock.
23-
To take advantage of the additional features, you must which information you
23+
To take advantage of the additional features, you must define on which information you
2424
want to base the computation, by checking one or more boxes in the settings:
2525
`Inventory` > `Configuration` > `Settings` > `Stock available to promise`.
2626
In case of "Include the production potential", it is also possible to configure
@@ -73,4 +73,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
7373
mission is to support the collaborative development of Odoo features and
7474
promote its widespread use.
7575

76-
To contribute to this module, please visit https://odoo-community.org.
76+
To contribute to this module, please visit https://odoo-community.org.

stock_available/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# Copyright 2016 Sodexis
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5-
from . import product_template
65
from . import product_product
6+
from . import product_template
77
from . import res_config_settings

stock_available/models/product_product.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2016 Sodexis
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5-
from odoo import models, fields, api
5+
from odoo import api, fields, models
66
from odoo.addons import decimal_precision as dp
77
import operator as py_operator
88

@@ -18,7 +18,7 @@
1818

1919
class ProductProduct(models.Model):
2020

21-
"""Add a field for the stock available to promise.
21+
""" Add a field for the stock available to promise.
2222
Useful implementations need to be installed through the Settings menu or by
2323
installing one of the modules stock_available_*
2424
"""
@@ -39,7 +39,7 @@ def _compute_available_quantities_dict(self):
3939
def _compute_available_quantities(self):
4040
res = self._compute_available_quantities_dict()
4141
for product in self:
42-
for key, value in res[product.id].iteritems():
42+
for key, value in res[product.id].items():
4343
if hasattr(product, key):
4444
product[key] = value
4545

@@ -51,7 +51,7 @@ def _compute_available_quantities(self):
5151
help="Stock for this Product that can be safely proposed "
5252
"for sale to Customers.\n"
5353
"The definition of this value can be configured to suit "
54-
"your needs")
54+
"your needs.")
5555
potential_qty = fields.Float(
5656
compute='_compute_available_quantities',
5757
digits=dp.get_precision('Product Unit of Measure'),
@@ -61,8 +61,7 @@ def _compute_available_quantities(self):
6161

6262
@api.model
6363
def _search_immediately_usable_qty(self, operator, value):
64-
"""
65-
Search function for the immediately_usable_qty field.
64+
""" Search function for the immediately_usable_qty field.
6665
The search is quite similar to the Odoo search about quantity available
6766
(addons/stock/models/product.py,253; _search_product_quantity function)
6867
:param operator: str

stock_available/models/product_template.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ProductTemplate(models.Model):
2525
def _compute_available_quantities(self):
2626
res = self._compute_available_quantities_dict()
2727
for product in self:
28-
for key, value in res[product.id].iteritems():
28+
for key, value in res[product.id].items():
2929
if key in product._fields:
3030
product[key] = value
3131

@@ -67,8 +67,7 @@ def _compute_available_quantities_dict(self):
6767

6868
@api.model
6969
def _search_immediately_usable_qty(self, operator, value):
70-
"""
71-
Search function for the immediately_usable_qty field.
70+
""" Search function for the immediately_usable_qty field.
7271
The search is quite similar to the Odoo search about quantity available
7372
(addons/stock/models/product.py,253; _search_product_quantity function)
7473
:param operator: str

stock_available/models/res_config_settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2016 Sodexis
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5-
from odoo import api, models, fields
5+
from odoo import api, fields, models
66

77

88
class ResConfigSettings(models.TransientModel):

stock_available/views/product_product_view.xml

+28-28
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
55

66
<odoo>
7-
<record model="ir.ui.view" id="product_normal_form_view">
8-
<field name="name">Quantity available to promise (variant tree)</field>
9-
<field name="model">product.product</field>
10-
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
11-
<field name="arch" type="xml">
12-
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_product)d']"
13-
position="after">
14-
<button type="action" name="%(stock.product_open_quants)d"
15-
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
16-
class="oe_stat_button" icon="fa-building-o">
17-
<div class="o_form_field o_stat_info">
18-
<field name="immediately_usable_qty"
19-
widget="statinfo" nolabel="1" />
20-
<span class="o_stat_text">Available</span>
21-
</div>
22-
</button>
23-
<button type="action" name="%(stock.product_open_quants)d"
24-
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
25-
class="oe_stat_button" icon="fa-building-o">
26-
<div class="o_form_field o_stat_info">
27-
<field name="potential_qty"
28-
widget="statinfo" nolabel="1"/>
29-
<span class="o_stat_text">Potential</span>
30-
</div>
31-
</button>
32-
</xpath>
33-
</field>
34-
</record>
7+
<record model="ir.ui.view" id="product_normal_form_view">
8+
<field name="name">Quantity available to promise (variant tree)</field>
9+
<field name="model">product.product</field>
10+
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
11+
<field name="arch" type="xml">
12+
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_product)d']"
13+
position="after">
14+
<button type="action" name="%(stock.product_open_quants)d"
15+
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
16+
class="oe_stat_button" icon="fa-building-o">
17+
<div class="o_form_field o_stat_info">
18+
<field name="immediately_usable_qty"
19+
widget="statinfo" nolabel="1" />
20+
<span class="o_stat_text">Available</span>
21+
</div>
22+
</button>
23+
<button type="action" name="%(stock.product_open_quants)d"
24+
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
25+
class="oe_stat_button" icon="fa-building-o">
26+
<div class="o_form_field o_stat_info">
27+
<field name="potential_qty"
28+
widget="statinfo" nolabel="1"/>
29+
<span class="o_stat_text">Potential</span>
30+
</div>
31+
</button>
32+
</xpath>
33+
</field>
34+
</record>
3535
</odoo>

stock_available/views/product_template_view.xml

+51-51
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,56 @@
44
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
55

66
<odoo>
7-
<record model="ir.ui.view" id="view_stock_available_form">
8-
<field name="name">Quantity available to promise (form)</field>
9-
<field name="model">product.template</field>
10-
<field name="inherit_id" ref="stock.product_template_form_view_procurement_button" />
11-
<field name="arch" type="xml">
12-
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_template)d']"
13-
position="after">
14-
<button type="object" name="action_open_quants"
15-
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
16-
class="oe_stat_button" icon="fa-building-o">
17-
<div class="o_form_field o_stat_info">
18-
<field name="immediately_usable_qty"
19-
widget="statinfo" nolabel="1" />
20-
<span class="o_stat_text">Available</span>
21-
</div>
22-
</button>
23-
<button type="action" name="%(stock.product_open_quants)d"
24-
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
25-
class="oe_stat_button" icon="fa-building-o">
26-
<div class="o_form_field o_stat_info">
27-
<field name="potential_qty"
28-
widget="statinfo" nolabel="1"/>
29-
<span class="o_stat_text">Potential</span>
30-
</div>
31-
</button>
32-
</xpath>
7+
<record model="ir.ui.view" id="view_stock_available_form">
8+
<field name="name">Quantity available to promise (form)</field>
9+
<field name="model">product.template</field>
10+
<field name="inherit_id" ref="stock.product_template_form_view_procurement_button" />
11+
<field name="arch" type="xml">
12+
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_template)d']"
13+
position="after">
14+
<button type="object" name="action_open_quants"
15+
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
16+
class="oe_stat_button" icon="fa-building-o">
17+
<div class="o_form_field o_stat_info">
18+
<field name="immediately_usable_qty"
19+
widget="statinfo" nolabel="1" />
20+
<span class="o_stat_text">Available</span>
21+
</div>
22+
</button>
23+
<button type="action" name="%(stock.product_open_quants)d"
24+
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
25+
class="oe_stat_button" icon="fa-building-o">
26+
<div class="o_form_field o_stat_info">
27+
<field name="potential_qty"
28+
widget="statinfo" nolabel="1"/>
29+
<span class="o_stat_text">Potential</span>
30+
</div>
31+
</button>
32+
</xpath>
33+
</field>
34+
</record>
35+
<record model="ir.ui.view" id="view_stock_available_tree">
36+
<field name="name">Quantity available to promise (tree)</field>
37+
<field name="model">product.template</field>
38+
<field name="inherit_id" ref="stock.view_stock_product_template_tree"/>
39+
<field name="arch" type="xml">
40+
<tree position="attributes">
41+
<attribute name="decoration-danger">virtual_available&lt;0 or immediately_usable_qty&lt;0</attribute>
42+
<attribute name="decoration-info">virtual_available&gt;=0 or immediately_usable_qty&gt;0</attribute>
43+
</tree>
44+
<field name="virtual_available" position="after">
45+
<field name="immediately_usable_qty" />
3346
</field>
34-
</record>
35-
<record model="ir.ui.view" id="view_stock_available_tree">
36-
<field name="name">Quantity available to promise (tree)</field>
37-
<field name="model">product.template</field>
38-
<field name="inherit_id" ref="stock.view_stock_product_template_tree"/>
39-
<field name="arch" type="xml">
40-
<tree position="attributes">
41-
<attribute name="decoration-danger">virtual_available&lt;0 or immediately_usable_qty&lt;0</attribute>
42-
<attribute name="decoration-info">virtual_available&gt;=0 or immediately_usable_qty&gt;0</attribute>
43-
</tree>
44-
<field name="virtual_available" position="after">
45-
<field name="immediately_usable_qty" />
46-
</field>
47-
</field>
48-
</record>
49-
<record model="ir.ui.view" id="view_stock_available_kanban">
50-
<field name="name">Quantity available to promise (kanban)</field>
51-
<field name="model">product.template</field>
52-
<field name="inherit_id" ref="stock.product_template_kanban_stock_view"/>
53-
<field name="arch" type="xml">
54-
<ul position="inside">
55-
<li t-if="record.type.raw_value == 'product'">Available to Promise: <field name="immediately_usable_qty"/> <field name="uom_id"/></li>
56-
</ul>
57-
</field>
58-
</record>
47+
</field>
48+
</record>
49+
<record model="ir.ui.view" id="view_stock_available_kanban">
50+
<field name="name">Quantity available to promise (kanban)</field>
51+
<field name="model">product.template</field>
52+
<field name="inherit_id" ref="stock.product_template_kanban_stock_view"/>
53+
<field name="arch" type="xml">
54+
<ul position="inside">
55+
<li t-if="record.type.raw_value == 'product'">Available to Promise: <field name="immediately_usable_qty"/> <field name="uom_id"/></li>
56+
</ul>
57+
</field>
58+
</record>
5959
</odoo>

stock_available/views/res_config_settings_views.xml

+21-53
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,32 @@
99
<field name="model">res.config.settings</field>
1010
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
1111
<field name="arch" type="xml">
12-
<data>
13-
<xpath expr="//div[@data-key='stock']" position="inside">
14-
<h2 id="available_info">Stock available to promise</h2>
15-
<div class="row mt16 o_settings_container">
16-
<div class="col-xs-12 col-md-6 o_setting_box">
17-
<div class="o_setting_left_pane">
18-
<field name="module_stock_available_immediately"/>
19-
</div>
20-
<div class="o_setting_right_pane">
21-
<label for="module_stock_available_immediately"/>
22-
</div>
12+
<xpath expr="//div[@data-key='stock']" position="inside">
13+
<h2 id="available_info">Stock available to promise</h2>
14+
<div class="row mt16 o_settings_container">
15+
<div class="col-xs-12 col-md-6 o_setting_box">
16+
<div class="o_setting_left_pane">
17+
<field name="module_stock_available_immediately"/>
2318
</div>
24-
<div class="col-xs-12 col-md-6 o_setting_box">
25-
<div class="o_setting_left_pane">
26-
<field name="module_stock_available_mrp"/>
27-
</div>
28-
<div class="o_setting_right_pane">
29-
<label for="module_stock_available_mrp"/>
30-
<div class="content-group">
31-
<div class="mt16" attrs="{'invisible': [('module_stock_available_mrp', '=', False)]}">
32-
<field name="stock_available_mrp_based_on" class="oe_inline" attrs="{'required':[('module_stock_available_mrp','=',True)]}"/>
33-
</div>
34-
</div>
35-
</div>
19+
<div class="o_setting_right_pane">
20+
<label for="module_stock_available_immediately"/>
3621
</div>
37-
38-
<!--<div>-->
39-
<!--<field name="module_stock_available_sale" class="oe_inline" />-->
40-
<!--<label for="module_stock_available_sale" />-->
41-
<!--</div>-->
42-
<!--
43-
<div class="col-xs-12 col-md-6 o_setting_box" id="propagation_info" title="Rescheduling applies to any chain of operations (e.g. Make To Order, Pick Pack Ship). In the case of MTO sales, a vendor delay (updated incoming date) impacts the expected delivery date to the customer. This option allows to not propagate the rescheduling if the change is not critical.">
44-
<div class="o_setting_left_pane">
45-
<field name="use_propagation_minimum_delta"/>
46-
</div>
47-
<div class="o_setting_right_pane">
48-
<label for="use_propagation_minimum_delta"/>
49-
<div class="text-muted">
50-
Don’t propagate scheduling changes through chains of operations
51-
</div>
52-
<div class="content-group">
53-
<div class="mt16" attrs="{'invisible': [('use_propagation_minimum_delta', '=', False)]}">
54-
<span>Change must be higher than <field name="propagation_minimum_delta" class="oe_inline"/> days to be propagated</span>
55-
</div>
56-
</div>
22+
</div>
23+
<div class="col-xs-12 col-md-6 o_setting_box">
24+
<div class="o_setting_left_pane">
25+
<field name="module_stock_available_mrp"/>
26+
</div>
27+
<div class="o_setting_right_pane">
28+
<label for="module_stock_available_mrp"/>
29+
<div class="content-group">
30+
<div class="mt16" attrs="{'invisible': [('module_stock_available_mrp', '=', False)]}">
31+
<field name="stock_available_mrp_based_on" class="oe_inline" attrs="{'required':[('module_stock_available_mrp','=',True)]}"/>
5732
</div>
5833
</div>
59-
60-
61-
<div>
62-
<field name="module_stock_available_mrp" class="oe_inline" />
63-
<label for="module_stock_available_mrp" />
64-
<label for="stock_available_mrp_based_on" />
65-
<field name="stock_available_mrp_based_on" class="oe_inline" attrs="{'required':[('module_stock_available_mrp','=',True)]}"/>
66-
</div> -->
34+
</div>
6735
</div>
68-
</xpath>
69-
</data>
36+
</div>
37+
</xpath>
7038
</field>
7139
</record>
7240
</odoo>

0 commit comments

Comments
 (0)