mirror of
https://github.com/NaN-tic/trytond-stock_measurements_shape.git
synced 2023-12-13 21:20:09 +01:00
Add wizard to bom inputs/outputs to create/find product with different shape/measurements
This commit is contained in:
parent
d6dbc6e92b
commit
c6e9608b0f
5 changed files with 74 additions and 4 deletions
|
@ -14,6 +14,14 @@ msgctxt "error:product.measurements_shape_creation:"
|
|||
msgid "The stock move is not in draft state."
|
||||
msgstr "La línia d'albarà no està en estat esborrany."
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_bom_input_measurements_shape_creation"
|
||||
msgid "Create/Find product with same code and different shape/measurements"
|
||||
msgstr "Crea/Cerca producte amb el mateix codi i diferent forma/mesures"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_bom_output_measurements_shape_creation"
|
||||
msgid "Create/Find product with same code and different shape/measurements"
|
||||
msgstr "Crea/Cerca producte amb el mateix codi i diferent forma/mesures"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_purchase_measurements_shape_creation"
|
||||
msgid "Create/Find product with same code and different shape/measurements"
|
||||
msgstr "Crea/Cerca producte amb el mateix codi i diferent forma/mesures"
|
||||
|
|
|
@ -14,6 +14,14 @@ msgctxt "error:product.measurements_shape_creation:"
|
|||
msgid "The stock move is not in draft state."
|
||||
msgstr "La línea de albarán no está en estado borrador."
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_bom_input_measurements_shape_creation"
|
||||
msgid "Create/Find product with same code and different shape/measurements"
|
||||
msgstr "Crear/Buscar producto con el mismo código y distinta forma/medidas"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_bom_output_measurements_shape_creation"
|
||||
msgid "Create/Find product with same code and different shape/measurements"
|
||||
msgstr "Crear/Buscar producto con el mismo código y distinta forma/medidas"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_purchase_measurements_shape_creation"
|
||||
msgid "Create/Find product with same code and different shape/measurements"
|
||||
msgstr "Crear/Buscar producto con el mismo código y distinta forma/medidas"
|
||||
|
|
21
product.py
21
product.py
|
@ -8,6 +8,9 @@ from trytond.transaction import Transaction
|
|||
__all__ = ['ProductMeasurementsShapeCreation']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
MODELS = ['stock.move', 'sale.line', 'purchase.line', 'production.bom.input',
|
||||
'production.bom.output']
|
||||
|
||||
|
||||
class ProductMeasurementsShapeCreation(Wizard):
|
||||
__name__ = 'product.measurements_shape_creation'
|
||||
|
@ -27,10 +30,11 @@ class ProductMeasurementsShapeCreation(Wizard):
|
|||
Move = pool.get('stock.move')
|
||||
SaleLine = pool.get('sale.line')
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
BOMInput = pool.get('production.bom.input')
|
||||
BOMOutput = pool.get('production.bom.output')
|
||||
|
||||
context = Transaction().context
|
||||
if context['active_model'] in ['stock.move', 'sale.line',
|
||||
'purchase.line']:
|
||||
if context['active_model'] in MODELS:
|
||||
if context['active_model'] == 'stock.move':
|
||||
line = Move(context['active_id'])
|
||||
if line.state != 'draft':
|
||||
|
@ -43,6 +47,10 @@ class ProductMeasurementsShapeCreation(Wizard):
|
|||
line = PurchaseLine(context['active_id'])
|
||||
if line.purchase.state != 'draft':
|
||||
self.raise_user_error('purchase_readonly')
|
||||
elif context['active_model'] == 'production.bom.input':
|
||||
line = BOMInput(context['active_id'])
|
||||
elif context['active_model'] == 'production.bom.output':
|
||||
line = BOMOutput(context['active_id'])
|
||||
product_id = line.product.id
|
||||
new_context = {
|
||||
'active_model': 'product.product',
|
||||
|
@ -60,16 +68,21 @@ class ProductMeasurementsShapeCreation(Wizard):
|
|||
Move = pool.get('stock.move')
|
||||
SaleLine = pool.get('sale.line')
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
BOMInput = pool.get('production.bom.input')
|
||||
BOMOutput = pool.get('production.bom.output')
|
||||
|
||||
context = Transaction().context
|
||||
if context['active_model'] in ['stock.move', 'sale.line',
|
||||
'purchase.line']:
|
||||
if context['active_model'] in MODELS:
|
||||
if context['active_model'] == 'stock.move':
|
||||
line = Move(context['active_id'])
|
||||
elif context['active_model'] == 'sale.line':
|
||||
line = SaleLine(context['active_id'])
|
||||
elif context['active_model'] == 'purchase.line':
|
||||
line = PurchaseLine(context['active_id'])
|
||||
elif context['active_model'] == 'production.bom.input':
|
||||
line = BOMInput(context['active_id'])
|
||||
elif context['active_model'] == 'production.bom.output':
|
||||
line = BOMOutput(context['active_id'])
|
||||
template = line.product.template
|
||||
new_template = self.create_find(template)
|
||||
line.product = new_template.products[0]
|
||||
|
|
40
product.xml
40
product.xml
|
@ -62,5 +62,45 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
ref="wizard_purchase_measurements_shape_creation"/>
|
||||
<field name="group" ref="product.group_product_admin"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard"
|
||||
id="wizard_bom_input_measurements_shape_creation">
|
||||
<field name="name">Create/Find product with same code and different shape/measurements</field>
|
||||
<field name="wiz_name">product.measurements_shape_creation</field>
|
||||
<field name="model">production.bom.input</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword"
|
||||
id="act_bom_input_measurements_shape_creation_keyword1">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">production.bom.input,-1</field>
|
||||
<field name="action"
|
||||
ref="wizard_bom_input_measurements_shape_creation"/>
|
||||
</record>
|
||||
<record model="ir.action-res.group"
|
||||
id="wizard_bom_input_measurements_shape_creation-group_product_admin">
|
||||
<field name="action"
|
||||
ref="wizard_bom_input_measurements_shape_creation"/>
|
||||
<field name="group" ref="product.group_product_admin"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard"
|
||||
id="wizard_bom_output_measurements_shape_creation">
|
||||
<field name="name">Create/Find product with same code and different shape/measurements</field>
|
||||
<field name="wiz_name">product.measurements_shape_creation</field>
|
||||
<field name="model">production.bom.output</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword"
|
||||
id="act_bom_output_measurements_shape_creation_keyword1">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">production.bom.output,-1</field>
|
||||
<field name="action"
|
||||
ref="wizard_bom_output_measurements_shape_creation"/>
|
||||
</record>
|
||||
<record model="ir.action-res.group"
|
||||
id="wizard_bom_output_measurements_shape_creation-group_product_admin">
|
||||
<field name="action"
|
||||
ref="wizard_bom_output_measurements_shape_creation"/>
|
||||
<field name="group" ref="product.group_product_admin"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -6,5 +6,6 @@ depends:
|
|||
stock
|
||||
sale
|
||||
purchase
|
||||
production
|
||||
xml:
|
||||
product.xml
|
||||
|
|
Loading…
Reference in a new issue