[MIG] stock_available: Migration to 13.0

This commit is contained in:
ps-tubtim
2020-06-16 13:37:06 +07:00
committed by Florian da Costa
parent dd90188d8a
commit b546d23d27
9 changed files with 144 additions and 77 deletions

View File

@@ -14,13 +14,13 @@ Stock available to promise
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_available
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/12.0
:target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_available%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_available%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -95,6 +95,10 @@ Contributors
* Sergio Teruel <sergio.teruel@tecnativa.com>
* `Ecosoft <http://ecosoft.co.th/>`_:
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
Maintainers
~~~~~~~~~~~
@@ -108,6 +112,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,7 +4,6 @@
from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
from odoo.addons.stock.models.product import OPERATORS
@@ -17,7 +16,6 @@ class ProductProduct(models.Model):
_inherit = "product.product"
@api.multi
def _compute_available_quantities_dict(self):
stock_dict = self._compute_quantities_dict(
self._context.get("lot_id"),
@@ -34,7 +32,6 @@ class ProductProduct(models.Model):
}
return res, stock_dict
@api.multi
@api.depends("virtual_available")
def _compute_available_quantities(self):
res, _ = self._compute_available_quantities_dict()
@@ -44,7 +41,7 @@ class ProductProduct(models.Model):
product[key] = value
immediately_usable_qty = fields.Float(
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
compute="_compute_available_quantities",
search="_search_immediately_usable_qty",
string="Available to promise",
@@ -55,7 +52,7 @@ class ProductProduct(models.Model):
)
potential_qty = fields.Float(
compute="_compute_available_quantities",
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
string="Potential",
help="Quantity of this Product that could be produced using "
"the materials already at hand.",

View File

@@ -4,14 +4,12 @@
from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
from odoo.addons.stock.models.product import OPERATORS
class ProductTemplate(models.Model):
_inherit = "product.template"
@api.multi
@api.depends(
"product_variant_ids.immediately_usable_qty",
"product_variant_ids.potential_qty",
@@ -23,7 +21,6 @@ class ProductTemplate(models.Model):
if key in product._fields:
product[key] = value
@api.multi
def _compute_available_quantities_dict(self):
variants_dict, _ = self.mapped(
"product_variant_ids"
@@ -51,7 +48,7 @@ class ProductTemplate(models.Model):
return res
immediately_usable_qty = fields.Float(
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
compute="_compute_available_quantities",
search="_search_immediately_usable_qty",
string="Available to promise",
@@ -62,7 +59,7 @@ class ProductTemplate(models.Model):
)
potential_qty = fields.Float(
compute="_compute_available_quantities",
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
string="Potential",
help="Quantity of this Product that could be produced using "
"the materials already at hand. "

View File

@@ -66,7 +66,6 @@ class ResConfigSettings(models.TransientModel):
)
return res
@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
self.env["ir.config_parameter"].sudo().set_param(

View File

@@ -13,3 +13,7 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Sergio Teruel <sergio.teruel@tecnativa.com>
* `Ecosoft <http://ecosoft.co.th/>`_:
* Pimolnat Suntian <pimolnats@ecosoft.co.th>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_available"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module proposes several options to compute the quantity available to
promise for each product.
This quantity is based on the projected stock and, depending on the
@@ -411,7 +411,7 @@ chose to base the computation on.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_available%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_available%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -454,6 +454,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</blockquote>
</li>
<li><p class="first"><a class="reference external" href="http://ecosoft.co.th/">Ecosoft</a>:</p>
<blockquote>
<ul class="simple">
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
</ul>
</blockquote>
</li>
</ul>
</div>
<div class="section" id="maintainers">
@@ -463,7 +470,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_available">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -2,32 +2,51 @@
<!-- Copyright 2014 Numérigraphe
Copyright 2016 Sodexis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="ir.ui.view" id="product_normal_form_view">
<field name="name">Quantity available to promise (variant tree)</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
<field name="arch" type="xml">
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_product)d']"
position="after">
<button type="action" name="%(stock.product_open_quants)d"
<xpath
expr="//button[@name='action_product_forecast_report']"
position="after"
>
<button
type="object"
name="action_open_quants"
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
class="oe_stat_button" icon="fa-building-o">
class="oe_stat_button"
icon="fa-building-o"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value" widget="statinfo">
<field name="immediately_usable_qty" widget="statinfo" nolabel="1" class="mr4"/>
<field
name="immediately_usable_qty"
widget="statinfo"
nolabel="1"
class="mr4"
/>
<field name="uom_name" />
</span>
<span class="o_stat_text">Available</span>
</div>
</button>
<button type="action" name="%(stock.product_open_quants)d"
<button
type="object"
name="action_open_quants"
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
class="oe_stat_button" icon="fa-building-o">
class="oe_stat_button"
icon="fa-building-o"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value" widget="statinfo">
<field name="potential_qty" widget="statinfo" nolabel="1" class="mr4"/>
<field
name="potential_qty"
widget="statinfo"
nolabel="1"
class="mr4"
/>
<field name="uom_name" />
</span>
<span class="o_stat_text">Potential</span>
@@ -42,8 +61,12 @@
<field name="inherit_id" ref="stock.view_stock_product_tree" />
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="decoration-danger">virtual_available&lt;0 or immediately_usable_qty&lt;0</attribute>
<attribute name="decoration-info">virtual_available&gt;=0 or immediately_usable_qty&gt;0</attribute>
<attribute
name="decoration-danger"
>virtual_available&lt;0 or immediately_usable_qty&lt;0</attribute>
<attribute
name="decoration-info"
>virtual_available&gt;=0 or immediately_usable_qty&gt;0</attribute>
</tree>
<field name="virtual_available" position="after">
<field name="immediately_usable_qty" />

View File

@@ -2,32 +2,54 @@
<!-- Copyright 2014 Numérigraphe
Copyright 2016 Sodexis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="ir.ui.view" id="view_stock_available_form">
<field name="name">Quantity available to promise (form)</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_form_view_procurement_button" />
<field
name="inherit_id"
ref="stock.product_template_form_view_procurement_button"
/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_template)d']"
position="after">
<button type="object" name="action_open_quants"
<xpath
expr="//button[@name='action_product_tmpl_forecast_report']"
position="after"
>
<button
type="object"
name="action_open_quants"
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
class="oe_stat_button" icon="fa-building-o">
class="oe_stat_button"
icon="fa-building-o"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value" widget="statinfo">
<field name="immediately_usable_qty" widget="statinfo" nolabel="1" class="mr4"/>
<field
name="immediately_usable_qty"
widget="statinfo"
nolabel="1"
class="mr4"
/>
<field name="uom_name" />
</span>
<span class="o_stat_text">Available</span>
</div>
</button>
<button type="action" name="%(stock.product_open_quants)d"
<button
type="object"
name="action_open_quants"
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
class="oe_stat_button" icon="fa-building-o">
class="oe_stat_button"
icon="fa-building-o"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value" widget="statinfo">
<field name="potential_qty" widget="statinfo" nolabel="1" class="mr4"/>
<field
name="potential_qty"
widget="statinfo"
nolabel="1"
class="mr4"
/>
<field name="uom_name" />
</span>
<span class="o_stat_text">Potential</span>
@@ -42,8 +64,12 @@
<field name="inherit_id" ref="stock.view_stock_product_template_tree" />
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="decoration-danger">virtual_available&lt;0 or immediately_usable_qty&lt;0</attribute>
<attribute name="decoration-info">virtual_available&gt;=0 or immediately_usable_qty&gt;0</attribute>
<attribute
name="decoration-danger"
>virtual_available&lt;0 or immediately_usable_qty&lt;0</attribute>
<attribute
name="decoration-info"
>virtual_available&gt;=0 or immediately_usable_qty&gt;0</attribute>
</tree>
<field name="virtual_available" position="after">
<field name="immediately_usable_qty" />
@@ -56,7 +82,11 @@
<field name="inherit_id" ref="stock.product_template_kanban_stock_view" />
<field name="arch" type="xml">
<ul position="inside">
<li t-if="record.type.raw_value == 'product'">Available to Promise: <field name="immediately_usable_qty"/> <field name="uom_id"/></li>
<li
t-if="record.type.raw_value == 'product'"
>Available to Promise: <field name="immediately_usable_qty" /> <field
name="uom_id"
/></li>
</ul>
</field>
</record>

View File

@@ -2,7 +2,6 @@
<!-- Copyright 2014 Numérigraphe
Copyright 2016 Sodexis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record id="view_stock_configuration" model="ir.ui.view">
<field name="name">Stock settings: quantity available to promise</field>
@@ -27,8 +26,15 @@
<div class="o_setting_right_pane">
<label for="module_stock_available_mrp" />
<div class="content-group">
<div class="mt16" attrs="{'invisible': [('module_stock_available_mrp', '=', False)]}">
<field name="stock_available_mrp_based_on" class="oe_inline" attrs="{'required':[('module_stock_available_mrp','=',True)]}"/>
<div
class="mt16"
attrs="{'invisible': [('module_stock_available_mrp', '=', False)]}"
>
<field
name="stock_available_mrp_based_on"
class="oe_inline"
attrs="{'required':[('module_stock_available_mrp','=',True)]}"
/>
</div>
</div>
</div>