Skip to content

Commit

Permalink
[FIX] version_modules: possibility to change product version selectin…
Browse files Browse the repository at this point in the history
…g other value in version value lines (#92)
  • Loading branch information
mikelarre committed May 25, 2021
1 parent c1ec9ec commit 458bd4a
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 458 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Production inherited attributes",
"version": "12.0.1.0.2",
"version": "12.0.1.0.3",
"license": "AGPL-3",
"depends": [
"mrp_hook", "mrp_scheduled_products", "product_variant_custom",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ class MrpProduction(models.Model):
related=False, states={'draft': [('readonly', False)]})
product_version_id = fields.Many2one(comodel_name="product.version",
name="Product Version")
version_value_ids = fields.One2many(
comodel_name="product.version.line",
related="product_version_id.custom_value_ids")
custom_value_ids = fields.One2many(
comodel_name="production.product.version.custom.line",
string="Custom Values",
inverse_name="line_id", copy=True)
inverse_name="line_id", copy=True, readonly=True,
states={'draft': [('readonly', False)]},)
product_attribute_ids = fields.One2many(
comodel_name='mrp.production.attribute', inverse_name='mrp_production',
string='Product attributes', copy=True, readonly=True,
Expand Down Expand Up @@ -120,8 +118,8 @@ def _set_custom_lines(self):
def product_version_id_change(self):
if self.product_version_id:
self.product_id = self.product_version_id.product_id
self.custom_value_ids = self._delete_custom_lines()
self.custom_value_ids = self._set_custom_lines()
self.custom_value_ids = self._delete_custom_lines()
self.custom_value_ids = self._set_custom_lines()

@api.multi
def _onchange_bom_id(self):
Expand Down Expand Up @@ -409,9 +407,6 @@ class MrpProductionProductLine(models.Model):
copy=True)
product_version_id = fields.Many2one(comodel_name="product.version",
name="Product Version")
version_value_ids = fields.One2many(
comodel_name="product.version.line",
related="product_version_id.custom_value_ids")
custom_value_ids = fields.One2many(
comodel_name="mrp.production.product.version.custom.line",
string="Custom Values",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
<field name="possible_value_ids" invisible="1" />
</tree>
</field>
<field name="version_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','=',False)], 'readonly': 1}"/>
<!--<field name="possible_attribute_ids" invisible="1"/>-->
<field name="custom_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','!=',False)]}">
<field name="custom_value_ids" context="{'show_attribute': False}">
<tree string="Product Version Line" editable="bottom" create="false">
<!--<field name="attribute_id" domain="[('id', 'in', parent.possible_attribute_ids[0][2])]"/>-->
<field name="attribute_id"/>
Expand Down Expand Up @@ -55,6 +52,9 @@
<field name="product_id" position="attributes">
<attribute name="string">Product Variants</attribute>
</field>
<field name="product_id" position="after">
<field name="product_version_id" />
</field>
</field>
</record>

Expand Down Expand Up @@ -123,11 +123,8 @@
<field name="possible_value_ids" invisible="1" />
</tree>
</field>
<field name="version_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','=',False)], 'readonly': 1}"/>
<!--<field name="possible_attribute_ids" invisible="1"/>-->
<field name="custom_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','!=',False)]}">
<field name="custom_value_ids" context="{'show_attribute': False}">
<tree string="Product Version Line" editable="bottom" create="false">
<!--<field name="attribute_id" domain="[('id', 'in', parent.possible_attribute_ids[0][2])]"/>-->
<field name="attribute_id"/>
Expand Down
2 changes: 1 addition & 1 deletion product_variant_custom/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ msgstr "El valor personalizado es mayor que el máximo permitido para este valor
#: code:addons/product_variant_custom/models/product_version.py:70
#, python-format
msgid "Custom value is smaller than minimum allowed for this value"
msgstr "El valor personalizado es menor que el máximo permitido para este valor"
msgstr "El valor personalizado es menor que el mínimo permitido para este valor"

#. module: product_variant_custom
#: model:ir.model.fields,field_description:product_variant_custom.field_product_version__partner_id
Expand Down
2 changes: 1 addition & 1 deletion product_variant_custom_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Purchase Product Version",
"version": "12.0.1.0.2",
"version": "12.0.1.0.3",
"license": "AGPL-3",
"depends": [
"purchase", "product_variant_custom",
Expand Down
12 changes: 5 additions & 7 deletions product_variant_custom_purchase/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ class PurchaseOrderLine(models.Model):
inverse_name='purchase_line_id',
string='Product attributes', copy=True, readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
version_value_ids = fields.One2many(
comodel_name="product.version.line",
related="product_version_id.custom_value_ids")
custom_value_ids = fields.One2many(
comodel_name="purchase.version.custom.line", string="Custom Values",
inverse_name="line_id", copy=True)
inverse_name="line_id", copy=True, readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
state = fields.Selection(default='draft')

def _delete_product_attribute_ids(self):
Expand Down Expand Up @@ -154,9 +152,9 @@ def _get_purchase_line_description(self):
def product_version_id_change(self):
if self.product_version_id:
self.product_id = self.product_version_id.product_id
self.name = self._get_purchase_line_description()
self.custom_value_ids = self._delete_custom_lines()
self.custom_value_ids = self._set_custom_lines()
self.custom_value_ids = self._delete_custom_lines()
self.custom_value_ids = self._set_custom_lines()
self.name = self._get_purchase_line_description()

@api.onchange('custom_value_ids')
def onchange_version_lines(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
</tree>
</field>
<field name="product_version_id" domain="[('product_id','=',product_id)]"/>
<field name="version_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','=',False)], 'readonly': 1}"/>
<!--<field name="possible_attribute_ids" invisible="1"/>-->
<field name="custom_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','!=',False)]}">
<field name="custom_value_ids" context="{'show_attribute': False}">
<tree string="Product Version Line" editable="bottom" create="false">
<!--<field name="attribute_id" domain="[('id', 'in', parent.possible_attribute_ids[0][2])]"/>-->
<field name="attribute_id"/>
Expand Down
2 changes: 1 addition & 1 deletion product_variant_custom_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Sale Product Version",
"version": "12.0.1.0.4",
"version": "12.0.1.0.5",
"license": "AGPL-3",
"depends": [
"sale",
Expand Down
10 changes: 4 additions & 6 deletions product_variant_custom_sale/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ class SaleOrderLine(models.Model):
comodel_name='sale.line.attribute', inverse_name='sale_line_id',
string='Product attributes', copy=True, readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
version_value_ids = fields.One2many(
comodel_name="product.version.line",
related="product_version_id.custom_value_ids")
custom_value_ids = fields.One2many(
comodel_name="sale.version.custom.line", string="Custom Values",
inverse_name="line_id", copy=True)
inverse_name="line_id", copy=True, readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
# possible_attribute_ids = fields.Many2many(
# comodel_name="product.attribute",
# compute="_compute_possible_attribute_ids")
Expand Down Expand Up @@ -247,8 +245,8 @@ def product_version_id_change(self):
if self.product_version_id:
self.product_id = self.product_version_id.product_id
self.name = self._get_sale_line_description()
self.custom_value_ids = self._delete_custom_lines()
self.custom_value_ids = self._set_custom_lines()
self.custom_value_ids = self._delete_custom_lines()
self.custom_value_ids = self._set_custom_lines()
self.name = self._get_sale_line_description()

@api.onchange('custom_value_ids')
Expand Down
9 changes: 2 additions & 7 deletions product_variant_custom_sale/views/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,9 @@
</field>
<field name="product_version_id"
domain="[('product_id','=',product_id)]"/>
<label for="version_value_ids" attrs="{'invisible': [('product_version_id','=',False)]}" colspan="2" />
<field name="version_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','=',False)], 'readonly': 1}"
nolabel="1" colspan="2"/>
<!--<field name="possible_attribute_ids" invisible="1"/>-->
<label for="custom_value_ids" attrs="{'invisible': [('product_version_id','!=',False)]}" colspan="2" />
<field name="custom_value_ids" context="{'show_attribute': False}"
attrs="{'invisible': [('product_version_id','!=',False)]}" nolabel="1" colspan="2">
<label for="custom_value_ids" colspan="2" />
<field name="custom_value_ids" context="{'show_attribute': False}" nolabel="1" colspan="2">
<tree string="Product Version Line" editable="bottom"
create="false">
<!--<field name="attribute_id" domain="[('id', 'in', parent.possible_attribute_ids[0][2])]"/>-->
Expand Down
2 changes: 1 addition & 1 deletion product_variant_custom_stock/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Stock Product Version Stock",
"version": "12.0.1.0.1",
"version": "12.0.1.0.2",
"license": "AGPL-3",
"depends": [
"product_variant_custom",
Expand Down
3 changes: 0 additions & 3 deletions product_variant_custom_stock/models/stock_production_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ class StockMove(models.Model):

product_version_id = fields.Many2one(comodel_name="product.version",
name="Product Version")
version_value_ids = fields.One2many(
comodel_name="product.version.line",
related="product_version_id.custom_value_ids")
custom_value_ids = fields.One2many(
comodel_name="lot.version.custom.line", string="Custom Values",
inverse_name="line_id", copy=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
<xpath expr="//field[@name='product_id']"
position="after">
<field name="product_version_id" domain="[('product_id','=',product_id)]"/>
<field name="version_value_ids"
attrs="{'invisible': [('product_version_id','=',False)], 'readonly': 1}"/>
<!--<field name="possible_attribute_ids" invisible="1"/>-->
<field name="custom_value_ids"
attrs="{'invisible': [('product_version_id','!=',False)]}">
<field name="custom_value_ids">
<tree string="Product Version Line" editable="bottom" create="false">
<!--<field name="attribute_id" domain="[('id', 'in', parent.possible_attribute_ids[0][2])]"/>-->
<field name="attribute_id"/>
Expand Down
5 changes: 1 addition & 4 deletions product_variant_custom_stock/views/stock_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
<xpath expr="//field[@name='product_id']"
position="after">
<field name="product_version_id" domain="[('product_id','=',product_id)]"/>
<field name="version_value_ids"
attrs="{'invisible': [('product_version_id','=',False)], 'readonly': 1}"/>
<!--<field name="possible_attribute_ids" invisible="1"/>-->
<field name="custom_value_ids"
attrs="{'invisible': [('product_version_id','!=',False)]}">
<field name="custom_value_ids">
<tree string="Product Version Line" editable="bottom" create="false">
<!--<field name="attribute_id" domain="[('id', 'in', parent.possible_attribute_ids[0][2])]"/>-->
<field name="attribute_id"/>
Expand Down

0 comments on commit 458bd4a

Please sign in to comment.