[MIG] purchase_usability to v14

This commit is contained in:
Alexis de Lattre
2020-12-02 21:32:47 +01:00
parent 44a4f795d0
commit f818bb5895
10 changed files with 89 additions and 129 deletions

View File

@@ -1,3 +1 @@
from . import purchase
from . import product
from . import partner
from . import models

View File

@@ -1,10 +1,10 @@
# Copyright (C) 2014-2019 Akretion (http://www.akretion.com)
# Copyright (C) 2014-2020 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Purchase Usability',
'version': '12.0.1.0.0',
'version': '14.0.1.0.0',
'category': 'Purchases',
'license': 'AGPL-3',
'summary': 'Usability improvements on purchase module',
@@ -12,7 +12,8 @@
'website': 'http://www.akretion.com',
'depends': ['purchase'],
'data': [
'purchase_view.xml',
'views/purchase_order.xml',
'views/purchase_report.xml',
],
'installable': False,
'installable': True,
}

View File

@@ -0,0 +1,3 @@
from . import purchase_order
from . import product_template
from . import res_partner

View File

@@ -0,0 +1,12 @@
# Copyright 2016-2020 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
purchase_method = fields.Selection(tracking=True)
purchase_line_warn = fields.Selection(tracking=True)

View File

@@ -1,26 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2019 Akretion France (http://www.akretion.com)
# Copyright 2015-2020 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
from odoo import api, fields, models
from odoo.tools.misc import formatLang
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
dest_address_id = fields.Many2one(track_visibility='onchange')
currency_id = fields.Many2one(track_visibility='onchange')
payment_term_id = fields.Many2one(track_visibility='onchange')
fiscal_position_id = fields.Many2one(track_visibility='onchange')
partner_ref = fields.Char(track_visibility='onchange')
# field 'partner_id': native value for track_visibility='always'
partner_id = fields.Many2one(track_visibility='onchange')
dest_address_id = fields.Many2one(tracking=True)
currency_id = fields.Many2one(tracking=True)
payment_term_id = fields.Many2one(tracking=True)
fiscal_position_id = fields.Many2one(tracking=True)
partner_ref = fields.Char(tracking=True)
# the field 'delivery_partner_id' is used in report
# the compute method of that field is inherited in purchase_stock_usability
delivery_partner_id = fields.Many2one(
'res.partner', compute='_compute_delivery_partner_id', readonly=True)
'res.partner', compute='_compute_delivery_partner_id')
@api.depends('dest_address_id')
def _compute_delivery_partner_id(self):
@@ -33,7 +30,6 @@ class PurchaseOrder(models.Model):
return action
# Re-write native name_get() to use amount_untaxed instead of amount_total
@api.multi
@api.depends('name', 'partner_ref')
def name_get(self):
result = []
@@ -41,7 +37,8 @@ class PurchaseOrder(models.Model):
name = po.name
if po.partner_ref:
name += ' (' + po.partner_ref + ')'
if self.env.context.get('show_total_amount') and po.amount_total:
name += ': ' + formatLang(self.env, po.amount_untaxed, currency_obj=po.currency_id)
if self.env.context.get('show_total_amount') and po.amount_untaxed:
name += ': ' + formatLang(
self.env, po.amount_untaxed, currency_obj=po.currency_id)
result.append((po.id, name))
return result

View File

@@ -1,11 +1,11 @@
# Copyright 2017-2019 Akretion France
# Copyright 2017-2020 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
purchase_warn = fields.Selection(track_visibility='onchange')
purchase_warn = fields.Selection(tracking=True)

View File

@@ -1,12 +0,0 @@
# Copyright 2016-2019 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class ProductTemplate(models.Model):
_inherit = 'product.template'
purchase_method = fields.Selection(track_visibility='onchange')
purchase_line_warn = fields.Selection(track_visibility='onchange')

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<record id="view_picking_form" model="ir.ui.view">
<field name="name">purchase_usability.stock.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<field name="origin" position="after">
<field name="purchase_id" attrs="{'invisible': [('picking_type_code', '!=', 'incoming')]}" context="{'show_purchase': True}"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014-2019 Akretion (http://www.akretion.com/)
Copyright 2014-2020 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
@@ -44,14 +44,9 @@
<field name="arch" type="xml">
<!-- the 'origin' field can be very long ; it can list a lot of MO or OP!
I think limiting the size of the field would not be the best option,
because the info it carries can be interesting. So we just remove it from
tree view to avoid layout issues -->
because the info it carries can be interesting. So we just hide it by default -->
<field name="origin" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="state" position="after">
<!-- State field is not sufficient to define what is the next step of the purchase-->
<field name="invoice_status"/>
<attribute name="optional">hide</attribute>
</field>
</field>
</record>
@@ -65,8 +60,8 @@
<filter string="Billing Status" name="invoice_status_groupby" context="{'group_by': 'invoice_status'}"/>
</group>
<field name="name" position="attributes">
<attribute name="string">Reference or Origin</attribute>
<attribute name="filter_domain">['|', ('name', 'ilike', self), ('origin', 'ilike', self)]</attribute>
<attribute name="string">Reference, Origin or Vendor Reference</attribute>
<attribute name="filter_domain">['|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('partner_ref', 'ilike', self)]</attribute>
</field>
</field>
</record>
@@ -108,7 +103,8 @@
<!-- Do not show cancelled quotations by default in "Requests for Quotation" -->
<record id="purchase.purchase_rfq" model="ir.actions.act_window">
<field name="context">{'search_default_draft': 1}</field>
<field name="context">{'search_default_draft': 1, 'quotation_only': True}</field>
<field name="domain">[('state', 'not in', ('purchase', 'done'))]</field>
</record>
<record id="purchase_order_line_tree" model="ir.ui.view">
@@ -130,7 +126,6 @@
</field>
<field name="product_qty" position="before">
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
<field name="currency_id" invisible="1"/>
</field>
<field name="date_planned" position="after">
<field name="state"/>
@@ -147,65 +142,9 @@
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
</field>
<group expand="0" position="inside">
<filter string="Analytic Account" name="account_analytic_groupby" context="{'group_by': 'account_analytic_id'}"/>
<filter string="Analytic Account" name="account_analytic_groupby" context="{'group_by': 'account_analytic_id'}" groups="analytic.group_analytic_accounting"/>
</group>
</field>
</record>
<record id="purchase_order_line_pivot" model="ir.ui.view">
<field name="name">usability.purchase.order.line.pivot</field>
<field name="model">purchase.order.line</field>
<field name="arch" type="xml">
<pivot string="Purchase Order Lines">
<field name="state" type="col"/>
<field name="partner_id" type="row"/>
<field name="price_subtotal" type="measure"/> <!-- not good, because it sums-up different currencies -->
</pivot>
</field>
</record>
<record id="purchase_order_line_action" model="ir.actions.act_window">
<field name="name">Purchase Order Lines</field>
<field name="res_model">purchase.order.line</field>
<field name="view_mode">tree,form,pivot</field>
</record>
<!-- The menu entry should be added in customer-specific module -->
<record id="purchase.action_purchase_order_report_all" model="ir.actions.act_window">
<field name="view_mode">pivot,graph,tree</field> <!--- native order is graph,pivot. Switch order and add tree -->
</record>
<record id="view_purchase_order_pivot" model="ir.ui.view">
<field name="model">purchase.report</field>
<field name="inherit_id" ref="purchase.view_purchase_order_pivot"/>
<field name="arch" type="xml">
<pivot position="attributes">
<attribute name="disable_linking"></attribute>
</pivot>
<field name="unit_quantity" position="replace"/> <!-- it's stupid to display a unit_quantity by default... it will sum qty of different products, which doesn't make a lot of sense -->
<field name="price_average" position="replace"/> <!-- it's stupid to display a price_average by default... it will average between different products, which is a non-sense -->
</field>
</record>
<record id="view_purchase_order_tree" model="ir.ui.view">
<field name="name">purchase.report.tree</field>
<field name="model">purchase.report</field>
<field name="arch" type="xml">
<tree>
<field name="commercial_partner_id"/>
<field name="date_order"/>
<field name="date_approve"/>
<field name="product_id"/>
<field name="unit_quantity" sum="1"/>
<field name="product_uom"/>
<field name="price_total" sum="1"/>
<field name="account_analytic_id"/>
<field name="currency_id" invisible="1"/>
<field name="user_id"/>
<field name="state"/>
</tree>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014-2020 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="purchase.action_purchase_order_report_all" model="ir.actions.act_window">
<field name="view_mode">pivot,graph,tree</field> <!--- native order is graph,pivot. Switch order and add tree -->
</record>
<record id="view_purchase_order_pivot" model="ir.ui.view">
<field name="model">purchase.report</field>
<field name="inherit_id" ref="purchase.view_purchase_order_pivot"/>
<field name="arch" type="xml">
<pivot position="attributes">
<attribute name="disable_linking"></attribute>
</pivot>
</field>
</record>
<record id="view_purchase_order_tree" model="ir.ui.view">
<field name="name">purchase.report.tree</field>
<field name="model">purchase.report</field>
<field name="arch" type="xml">
<tree>
<field name="commercial_partner_id"/>
<field name="date_order"/>
<field name="date_approve"/>
<field name="product_id"/>
<field name="qty_ordered" sum="1"/>
<field name="qty_received" sum="1"/>
<field name="qty_billed" sum="1"/>
<field name="product_uom"/>
<field name="price_total" sum="1"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
<field name="currency_id" invisible="1"/>
<field name="user_id"/>
<field name="state"/>
</tree>
</field>
</record>
</odoo>