Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG][12.0] ao_purchase_request #185

Open
wants to merge 5 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ao_purchase_request/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

==============================================
AO-specific customizations on purchase request
==============================================

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
=======

Contributors
------------

* Eficent Business and IT Consulting Services S.L. <[email protected]>
2 changes: 2 additions & 0 deletions ao_purchase_request/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
20 changes: 20 additions & 0 deletions ao_purchase_request/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# Copyright 2019 Aleph Objects, Inc.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "AO-specific customizations on purchase request",
"version": "12.0.1.0.0",
"author": "Eficent Business and IT Consulting Services S.L.",
"website": "http://www.eficent.com",
"category": "Product",
"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,
}
2 changes: 2 additions & 0 deletions ao_purchase_request/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +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)
14 changes: 14 additions & 0 deletions ao_purchase_request/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class StockRule(models.Model):
_inherit = 'stock.rule'

@api.model
def _make_pr_get_domain(self, values):
super(StockRule, self)._make_pr_get_domain(values)
domain = (('id', '=', 0),)
return domain
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,17 @@
# 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
from odoo.exceptions import UserError


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

product_type = fields.Selection(related='product_id.type', readonly=True)

def check_group(self, request_lines):
try:
super().check_group(request_lines)
except UserError:
# TODO: add some logic for handle this UserError in a better way
pass
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>

2 changes: 1 addition & 1 deletion oca_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ stock-rma https://github.com/Eficent/stock-rma.git
# module: ao_stock_account
# stock-logistics-reporting https://github.com/Eficent/stock-logistics-reporting.git 11.0-stock_account_valuation_report
# module: purchase_unreconciled
purchase-workflow
purchase-workflow https://github.com/Eficent/purchase-workflow.git 12.0-mig-purchase_request
account-financial-tools