Skip to content

Commit

Permalink
ao_purchase_request: Custom Purchase Request Product Usage
Browse files Browse the repository at this point in the history
  • Loading branch information
HviorForgeFlow committed Sep 12, 2019
1 parent de51454 commit 0bcf0b0
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ao_purchase_request/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ This module contains customizations specific to Aleph Objects.

* Disables the capability to group into a single purchase request
from various procurements.
* Purchase Request Product Usage custom workflow:
* Usage is seen by Purchase Request Users also
* Usage is required if Product is Consumible or a Service

Credits
=======
Expand Down
1 change: 1 addition & 0 deletions ao_purchase_request/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import wizards
8 changes: 7 additions & 1 deletion ao_purchase_request/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"author": "Eficent Business and IT Consulting Services S.L.",
"website": "http://www.eficent.com",
"category": "Product",
"depends": ["purchase_request"],
"depends": ["purchase_request",
"purchase_request_product_usage",
],
"data": [
"views/purchase_request_view.xml",
"wizards/purchase_request_line_make_purchase_order_view.xml",
],
"license": "AGPL-3",
'installable': True,
}
1 change: 1 addition & 0 deletions ao_purchase_request/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import stock_rule
from . import purchase_request
9 changes: 9 additions & 0 deletions ao_purchase_request/models/purchase_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class PurchaseRequestLine(models.Model):
_inherit = "purchase.request.line"

product_type = fields.Selection(related='product_id.type', readonly=True)
59 changes: 59 additions & 0 deletions ao_purchase_request/views/purchase_request_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<!-- Copyright 2018 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0) -->
<odoo>

<record model="ir.ui.view" id="view_purchase_request_form">
<field name="name">purchase.request.form</field>
<field name="model">purchase.request</field>
<field name="inherit_id" ref="purchase_request_product_usage.view_purchase_request_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']/tree/field[@name='usage_id']"
position="before">
<field name="product_type" invisible="1"/>
</xpath>
<xpath expr="//field[@name='line_ids']/tree/field[@name='usage_id']"
position="attributes">
<attribute name="attrs">{'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]}</attribute>
<attribute name="groups"/>
</xpath>
<xpath expr="//field[@name='line_ids']/form/sheet/group/group/field[@name='usage_id']"
position="before">
<field name="product_type" invisible="1"/>
</xpath>
<xpath expr="//field[@name='line_ids']/form/sheet/group/group/field[@name='usage_id']"
position="attributes">
<attribute name="attrs">{'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]}</attribute>
<attribute name="groups"/>
</xpath>
</field>
</record>

<record model="ir.ui.view" id="purchase_request_line_form">
<field name="name">purchase.request.line.form</field>
<field name="model">purchase.request.line</field>
<field name="inherit_id" ref="purchase_request_product_usage.purchase_request_line_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet/group/group/field[@name='usage_id']" position="before">
<field name="product_type" invisible="1"/>
</xpath>
<xpath expr="//sheet/group/group/field[@name='usage_id']" position="attributes">
<attribute name="attrs">{'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]}</attribute>
<attribute name="groups"/>
</xpath>
</field>
</record>

<record id="purchase_request_line_search" model="ir.ui.view">
<field name="name">purchase.request.line.search</field>
<field name="model">purchase.request.line</field>
<field name="inherit_id" ref="purchase_request_product_usage.purchase_request_line_search"/>
<field name="arch" type="xml">
<field name="usage_id" position="replace">
<field name="product_type" invisible="1"/>
<field name="usage_id" attrs="{'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]}"/>
</field>
</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions ao_purchase_request/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase_request_line_make_purchase_order
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).
from odoo import fields, models


class PurchaseRequestLineMakePurchaseOrderItem(models.TransientModel):
_inherit = "purchase.request.line.make.purchase.order.item"

product_type = fields.Selection(related='product_id.type', readonly=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0) -->
<odoo>

<record id="view_purchase_request_line_make_purchase_order" model="ir.ui.view">
<field name="name">Purchase Request Line Make Purchase Order</field>
<field name="model">purchase.request.line.make.purchase.order</field>
<field name="inherit_id" ref="purchase_request_product_usage.view_purchase_request_line_make_purchase_order"/>
<field name="arch" type="xml">
<field name="usage_id" position="replace">
<field name="product_type" invisible="1"/>
<field name="usage_id" attrs="{'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]}"/>
</field>
</field>
</record>

</odoo>

0 comments on commit 0bcf0b0

Please sign in to comment.