-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.0] rma_purchase: add purchase_policy
- Loading branch information
1 parent
a107228
commit 2100329
Showing
9 changed files
with
186 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2017 Eficent Business and IT Consulting Services S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2017 Eficent Business and IT Consulting Services S.L. | ||
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
{ | ||
'name': 'RMA Purchase', | ||
'version': '9.0.1.0.0', | ||
'version': '9.0.2.0.0', | ||
'category': 'RMA', | ||
'summary': 'RMA from PO', | ||
'license': 'LGPL-3', | ||
'author': 'Eficent, Odoo Community Association (OCA)', | ||
'website': 'http://www.github.com/OCA/rma', | ||
'depends': ['rma_account', 'purchase'], | ||
'data': ['views/rma_order_view.xml', | ||
'views/rma_order_line_view.xml', | ||
'wizards/rma_add_purchase.xml'], | ||
'data': [ | ||
'views/rma_operation_view.xml', | ||
'views/rma_order_view.xml', | ||
'views/rma_order_line_view.xml', | ||
'wizards/rma_add_purchase.xml', | ||
], | ||
'installable': True, | ||
'auto_install': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from openerp import api, fields, models | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = "purchase.order" | ||
|
||
@api.model | ||
def new(self, vals): | ||
"""Allows to propose a line based on the RMA information.""" | ||
res = super(PurchaseOrder, self).new(vals) | ||
rma_line_id = self.env.context.get('rma_line_id') | ||
if rma_line_id: | ||
rma_line = self.env['rma.order.line'].browse(rma_line_id) | ||
line = self.env['purchase.order.line'].new({ | ||
'product_id': rma_line.product_id.id, | ||
}) | ||
line.onchange_product_id() | ||
line.update({ | ||
'product_qty': rma_line.qty_to_purchase, | ||
'product_uom': rma_line.uom_id.id, | ||
}) | ||
res.order_line = line | ||
# TODO: maybe this line is not needed in v10: | ||
res.date_planned = res._compute_date_planned() | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Eficent Business and IT Consulting Services S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from openerp import api, fields, models, _ | ||
from openerp.exceptions import ValidationError | ||
|
||
|
||
class RmaOperation(models.Model): | ||
_inherit = 'rma.operation' | ||
|
||
purchase_policy = fields.Selection( | ||
selection=[('no', 'Not required'), | ||
('ordered', 'Based on Ordered Quantities'), | ||
('delivered', 'Based on Delivered Quantities')], | ||
string="Purchase Policy", default='no', | ||
) | ||
|
||
@api.multi | ||
@api.constrains('purchase_policy') | ||
def _check_purchase_policy(self): | ||
if self.filtered( | ||
lambda r: r.purchase_policy != 'no' and r.type != 'supplier'): | ||
raise ValidationError(_( | ||
'Purchase Policy can only apply to supplier operations')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2018 Eficent Business and IT Consulting Services S.L. | ||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) --> | ||
<odoo> | ||
|
||
<record id="rma_operation_tree" model="ir.ui.view"> | ||
<field name="name">rma.operation.tree - rma_purchase</field> | ||
<field name="model">rma.operation</field> | ||
<field name="inherit_id" ref="rma.rma_operation_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="delivery_policy" position="after"> | ||
<field name="purchase_policy"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="rma_operation_form" model="ir.ui.view"> | ||
<field name="name">rma.operation.form - rma_purchase</field> | ||
<field name="model">rma.operation</field> | ||
<field name="inherit_id" ref="rma.rma_operation_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="delivery_policy" position="after"> | ||
<field name="purchase_policy"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters