mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[ADD]rma_analytic
This commit is contained in:
committed by
Aaron ForgeFlow
parent
95566a0f36
commit
a2e0e1a902
34
rma_analytic/README.rst
Normal file
34
rma_analytic/README.rst
Normal file
@@ -0,0 +1,34 @@
|
||||
.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg
|
||||
:target: https://www.gnu.org/licenses/lgpl.html
|
||||
:alt: License: LGPL-3
|
||||
|
||||
==========================
|
||||
RMA with Analytic Accounts
|
||||
==========================
|
||||
|
||||
This module introduces the following features:
|
||||
|
||||
* Adds the analytic account to the RMA order lines.
|
||||
|
||||
* Propagates the analytic account to the procurements created
|
||||
|
||||
* Introduce rules to ensure consistency
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
* Add the analytic information in the rma line or let the system fill it
|
||||
from origin
|
||||
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Aaron Henriquez <ahenriquez@eficent.com>
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Eficent.
|
||||
5
rma_analytic/__init__.py
Normal file
5
rma_analytic/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from . import models
|
||||
from . import tests
|
||||
17
rma_analytic/__manifest__.py
Normal file
17
rma_analytic/__manifest__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- 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).
|
||||
|
||||
{
|
||||
"name": "Analytic Account in RMA",
|
||||
"version": "10.0.1.0.0",
|
||||
"author": "Eficent",
|
||||
"license": "LGPL-3",
|
||||
"website": "http://www.eficent.com",
|
||||
"category": "Analytic",
|
||||
"depends": ["rma", "analytic", "procurement_analytic"],
|
||||
"data": [
|
||||
"views/rma_order_line_view.xml"
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
4
rma_analytic/models/__init__.py
Normal file
4
rma_analytic/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from . import rma_order
|
||||
19
rma_analytic/models/procurement.py
Normal file
19
rma_analytic/models/procurement.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import _, api, exceptions, models
|
||||
|
||||
|
||||
class ProcurementOrder(models.Model):
|
||||
|
||||
_inherit = "procurement.order"
|
||||
|
||||
|
||||
@api.constrains('analytic_account_id')
|
||||
def check_analytic(self):
|
||||
for order in self:
|
||||
if order.analytic_account_id != order.rma_line_id.analytic_account_id:
|
||||
raise exceptions.ValidationError(
|
||||
_("The analytic account in the procurement it's not the same"
|
||||
" as in the rma line"))
|
||||
15
rma_analytic/models/rma_order_line.py
Normal file
15
rma_analytic/models/rma_order_line.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class RmaOrderLine(models.Model):
|
||||
|
||||
_inherit = "rma.order.line"
|
||||
|
||||
analytic_account_id = fields.Many2one(
|
||||
comodel_name='account.analytic',
|
||||
string='Analytic Account',
|
||||
)
|
||||
3
rma_analytic/tests/__init__.py
Normal file
3
rma_analytic/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
from . import test_rma_analytic
|
||||
30
rma_analytic/tests/test_rma_analytic.py
Normal file
30
rma_analytic/tests/test_rma_analytic.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- 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 test_rma
|
||||
|
||||
|
||||
class TestRmaAnalytic(test_rma.TestRma):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRmaAnalytic, self).setUp()
|
||||
products2move = [(self.product_1, 3), (self.product_2, 5),
|
||||
(self.product_3, 2)]
|
||||
self.rma_id = self._create_rma_from_move(
|
||||
products2move, 'supplier', self.env.ref('base.res_partner_1'),
|
||||
dropship=False)
|
||||
self.analytic_1 = self.env['account.analytic.account'].create({
|
||||
'name': 'Test account #1',
|
||||
})
|
||||
|
||||
def _prepare_move(self, product, qty, src, dest):
|
||||
res = super(TestRmaAnalytic, self)._prepare_move(
|
||||
product, qty, src, dest)
|
||||
res.update(analytic_account_id=self.analytic_1.id)
|
||||
return res
|
||||
|
||||
def test_analytic(self):
|
||||
for line in self.rma_id.line_ids:
|
||||
self.assertEqual(line.analytic_account_id, self.analytic_1,
|
||||
"the analytic account is not propagated")
|
||||
50
rma_analytic/views/rma_order_line_view.xml
Normal file
50
rma_analytic/views/rma_order_line_view.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- 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="view_rma_line_tree" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.tree</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_rma_line_supplier_tree" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.supplier.tree</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_rma_line_supplier_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.supplier.form</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="main_info" position="inside">
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_rma_line_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.form</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="arch" type="xml">
|
||||
<group name="main_info" position="inside">
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
|
||||
</group>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
5
rma_analytic/wizards/__init__.py
Normal file
5
rma_analytic/wizards/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from . import rma_add_stock_move
|
||||
17
rma_analytic/wizards/rma_add_stock_move.py
Normal file
17
rma_analytic/wizards/rma_add_stock_move.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class RmaAddStockMove(models.TransientModel):
|
||||
_inherit = 'rma_add_stock_move'
|
||||
_description = 'Wizard to add rma lines from pickings'
|
||||
|
||||
@api.model
|
||||
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||
data = super(RmaAddStockMove, self)._prepare_rma_line_from_stock_move(
|
||||
sm, lot)
|
||||
data.update(analytic_account_id=sm.analytic_account_id)
|
||||
return data
|
||||
18
rma_analytic/wizards/rma_make_picking.py
Normal file
18
rma_analytic/wizards/rma_make_picking.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo import models, api
|
||||
|
||||
|
||||
class RmaMakePicking(models.TransientModel):
|
||||
_name = 'rma_make_picking.wizard'
|
||||
_description = 'Wizard to create pickings from rma lines'
|
||||
|
||||
@api.model
|
||||
def _get_procurement_data(self, item, group, qty, picking_type):
|
||||
procurement_data = super(RmaMakePicking, self)._get_procurement_data(
|
||||
item, group, qty, picking_type)
|
||||
procurement_data.update(
|
||||
analytic_account_id=item.line_id.analytic_account_id.id)
|
||||
return procurement_data
|
||||
Reference in New Issue
Block a user