IMP rma_sale Add SO Smart Button link to related RMAs.

This commit is contained in:
Jared Kipe
2019-03-18 16:42:45 -07:00
committed by Jared Kipe
parent de01bbb121
commit a0debba9d0
4 changed files with 36 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
{
'name': 'Hibou RMAs for Sale Orders',
'version': '11.0.1.0.0',
'version': '11.0.1.1.0',
'category': 'Sale',
'author': "Hibou Corp.",
'license': 'AGPL-3',
@@ -16,6 +16,7 @@
'data': [
'security/ir.model.access.csv',
'views/rma_views.xml',
'views/sale_views.xml',
'wizard/rma_lines_views.xml',
],
'demo': [

View File

@@ -1 +1,2 @@
from . import rma
from . import sale

14
rma_sale/models/sale.py Normal file
View File

@@ -0,0 +1,14 @@
from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
rma_count = fields.Integer(string='RMA Count', compute='_compute_rma_count', compute_sudo=True)
rma_ids = fields.One2many('rma.rma', 'sale_order_id', string='RMAs')
@api.multi
@api.depends('rma_ids')
def _compute_rma_count(self):
for so in self:
so.rma_count = len(so.rma_ids)

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button name="%(rma.action_rma_rma)d" type="action" class="oe_stat_button" icon="fa-cubes"
attrs="{'invisible': [('rma_count', '=', 0)]}"
context="{'search_default_sale_order_id': active_id}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="rma_count"/></span> RMA
</div>
</button>
</xpath>
</field>
</record>
</odoo>