Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 7f85dda

Browse files
committed
Add missing files for purchase
1 parent da89fd4 commit 7f85dda

File tree

7 files changed

+163
-0
lines changed

7 files changed

+163
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#Odoo Product Configurator Purchase
2+
3+
This module is an extension to product configurator to add widjet to purchase and add possibility to choose a product variant instead of always create a new one.
4+
5+
Features
6+
========
7+
8+
- Add configure button to Purchase order.
9+
10+
Usage
11+
=====
12+
13+
To complete
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from . import models
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
3+
{
4+
'name': 'Product Configurator Purchase',
5+
'version': '10.0',
6+
'category': 'Generic Modules/Base',
7+
'summary': 'product configuration interface for purchase',
8+
'description': """
9+
Purchase Product Configurator
10+
""",
11+
'author': 'Microcom',
12+
'license': 'AGPL-3',
13+
'website': 'http://www.microcom.ca/',
14+
'depends': [
15+
'purchase',
16+
'product_configurator',
17+
'product_configurator_wizard',
18+
],
19+
"data": [
20+
'views/purchase_views.xml',
21+
],
22+
'demo': [
23+
],
24+
'images': [
25+
],
26+
'test': [],
27+
'installable': True,
28+
'auto_install': False,
29+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from . import purchase
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from odoo import models, fields, api
4+
5+
6+
class PurchaseOrderLine(models.Model):
7+
_inherit = 'purchase.order.line'
8+
9+
custom_value_ids = fields.One2many(
10+
comodel_name='product.attribute.value.custom',
11+
inverse_name='product_id',
12+
related="product_id.value_custom_ids",
13+
string="Custom Values"
14+
)
15+
16+
product_id = fields.Many2one(domain=[('config_ok', '=', False)])
17+
18+
config_ok = fields.Boolean(
19+
related='product_id.config_ok',
20+
string="Configurable"
21+
)
22+
23+
@api.multi
24+
def reconfigure_product(self):
25+
""" Creates and launches a product configurator wizard with a linked
26+
template and variant in order to re-configure a existing product. It is
27+
esetially a shortcut to pre-fill configuration data of a variant"""
28+
29+
cfg_steps = self.product_id.product_tmpl_id.config_step_line_ids
30+
active_step = str(cfg_steps[0].id) if cfg_steps else 'configure'
31+
32+
wizard_obj = self.env['product.configurator']
33+
wizard = wizard_obj.create({
34+
'product_id': self.product_id.id,
35+
'state': active_step,
36+
'purchase_order_line_id': self.id,
37+
})
38+
39+
return {
40+
'type': 'ir.actions.act_window',
41+
'res_model': 'product.configurator',
42+
'name': "Configure Product",
43+
'view_mode': 'form',
44+
'context': dict(
45+
self.env.context,
46+
wizard_id=wizard.id,
47+
),
48+
'target': 'new',
49+
'res_id': wizard.id,
50+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<section class="oe_container">
2+
<div class="oe_row oe_spaced">
3+
<div class="oe_span12">
4+
<h2 class="oe_slogan">Product Configurator Purchase</h2>
5+
<h3 class="oe_slogan">Generate products on-demand, easy and error-free</h3>
6+
</div>
7+
</div>
8+
</section>
9+
10+
<section class="oe_container mt64">
11+
<div class="oe_row oe_spaced">
12+
<h2 class="oe_slogan">Configure products directly in your purchase orders</h2>
13+
<h3 class="oe_slogan">This module is an extention to product configurator and Product configurator Wizard</h3>
14+
<h3 class="oe_slogan">It allow to configure product from purchase orders in addition to Sale orders</h3>
15+
</div>
16+
</section>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<!-- Add Configure Product button on sale order form view -->
5+
6+
<record id="action_wizard_product_purchase_configurator" model="ir.actions.act_window">
7+
<field name="name">Configure Product</field>
8+
<field name="res_model">product.configurator</field>
9+
<field name="view_mode">form</field>
10+
<field name="view_id" ref="product_configurator_wizard.product_configurator_form"/>
11+
<field name="target">new</field>
12+
</record>
13+
14+
<record id="purchase_order_form_config" model="ir.ui.view">
15+
<field name="name">purchase.order.form.config</field>
16+
<field name="model">purchase.order</field>
17+
<field name="inherit_id" ref="purchase.purchase_order_form"/>
18+
<field name="arch" type="xml">
19+
<xpath expr="//field[@name='order_line']" position="before">
20+
<button name="%(action_wizard_product_purchase_configurator)s"
21+
states="draft,sent"
22+
class="oe_highlight"
23+
type="action"
24+
style="margin-top: 15px;margin-bottom: 10px;"
25+
string="Configure Product"
26+
groups="product_configurator.group_product_configurator"/>
27+
</xpath>
28+
29+
<xpath expr="//field[@name='order_line']/form//field[@name='product_id']" position="after">
30+
<field name="config_ok" invisible="1"/>
31+
</xpath>
32+
33+
<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="after">
34+
<field name="config_ok" invisible="1"/>
35+
<button name="reconfigure_product" groups="product_configurator.group_product_configurator"
36+
help="Reconfigure"
37+
icon="fa-cogs"
38+
type="object"
39+
attrs="{
40+
'invisible': [
41+
'|',
42+
('config_ok','=',False),
43+
('state','not in',['draft','sent'])
44+
]}"/>
45+
</xpath>
46+
</field>
47+
</record>
48+
49+
</odoo>

0 commit comments

Comments
 (0)