[MIG] purchase_usability to v16
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# Copyright (C) 2014-2020 Akretion (http://www.akretion.com)
|
||||
# Copyright 2014-2022 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': '14.0.1.0.0',
|
||||
'version': '16.0.1.0.0',
|
||||
'category': 'Purchases',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Usability improvements on purchase module',
|
||||
@@ -16,5 +16,5 @@
|
||||
'views/purchase_report.xml',
|
||||
'views/account_move.xml',
|
||||
],
|
||||
'installable': False,
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016-2020 Akretion France
|
||||
# Copyright 2016-2022 Akretion France
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2015-2020 Akretion France (http://www.akretion.com)
|
||||
# Copyright 2015-2022 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).
|
||||
|
||||
@@ -85,7 +85,7 @@ class PurchaseOrderLine(models.Model):
|
||||
partner_id = line.order_id.partner_id.commercial_partner_id.id
|
||||
if partner_id:
|
||||
for supplier_info in line.product_id.seller_ids:
|
||||
if supplier_info.name.id == partner_id:
|
||||
if supplier_info.partner_id.id == partner_id:
|
||||
code = supplier_info.product_code
|
||||
break
|
||||
line.product_supplier_code = code
|
||||
@@ -101,40 +101,41 @@ class PurchaseOrderLine(models.Model):
|
||||
product_lang = product_lang.with_context(display_default_code=False)
|
||||
return super()._get_product_purchase_description(product_lang)
|
||||
|
||||
@api.onchange('product_qty', 'product_uom')
|
||||
def _onchange_quantity(self):
|
||||
# TODO see how we could restore this feature
|
||||
# @api.onchange('product_qty', 'product_uom')
|
||||
# def _onchange_quantity(self):
|
||||
# When the user has manually set a price and/or planned_date
|
||||
# he is often upset when Odoo changes it when he changes the qty
|
||||
# So we add a warning...
|
||||
res = {}
|
||||
old_price = self.price_unit
|
||||
old_date_planned = self.date_planned
|
||||
super()._onchange_quantity()
|
||||
new_price = self.price_unit
|
||||
new_date_planned = self.date_planned
|
||||
prec = self.env['decimal.precision'].precision_get('Product Price')
|
||||
price_compare = float_compare(old_price, new_price, precision_digits=prec)
|
||||
if price_compare or old_date_planned != new_date_planned:
|
||||
res['warning'] = {
|
||||
'title': _('Updates'),
|
||||
'message': _(
|
||||
"Due to the update of the ordered quantity on line '%s', "
|
||||
"the following data has been updated using the supplier info "
|
||||
"of the product:"
|
||||
) % self.name
|
||||
}
|
||||
if price_compare:
|
||||
res['warning']['message'] += _(
|
||||
"\nOld price: %s\nNew price: %s") % (
|
||||
format_amount(
|
||||
self.env, old_price, self.order_id.currency_id),
|
||||
format_amount(
|
||||
self.env, new_price, self.order_id.currency_id))
|
||||
# res = {}
|
||||
# old_price = self.price_unit
|
||||
# old_date_planned = self.date_planned
|
||||
# super()._onchange_quantity()
|
||||
# new_price = self.price_unit
|
||||
# new_date_planned = self.date_planned
|
||||
# prec = self.env['decimal.precision'].precision_get('Product Price')
|
||||
# price_compare = float_compare(old_price, new_price, precision_digits=prec)
|
||||
# if price_compare or old_date_planned != new_date_planned:
|
||||
# res['warning'] = {
|
||||
# 'title': _('Updates'),
|
||||
# 'message': _(
|
||||
# "Due to the update of the ordered quantity on line '%s', "
|
||||
# "the following data has been updated using the supplier info "
|
||||
# "of the product:"
|
||||
# ) % self.name
|
||||
# }
|
||||
# if price_compare:
|
||||
# res['warning']['message'] += _(
|
||||
# "\nOld price: %s\nNew price: %s") % (
|
||||
# format_amount(
|
||||
# self.env, old_price, self.order_id.currency_id),
|
||||
# format_amount(
|
||||
# self.env, new_price, self.order_id.currency_id))
|
||||
|
||||
if old_date_planned != new_date_planned:
|
||||
res['warning']['message'] += _(
|
||||
"\nOld delivery date: %s\nNew delivery date: %s") % (
|
||||
format_datetime(self.env, old_date_planned),
|
||||
format_datetime(self.env, new_date_planned),
|
||||
)
|
||||
return res
|
||||
# if old_date_planned != new_date_planned:
|
||||
# res['warning']['message'] += _(
|
||||
# "\nOld delivery date: %s\nNew delivery date: %s") % (
|
||||
# format_datetime(self.env, old_date_planned),
|
||||
# format_datetime(self.env, new_date_planned),
|
||||
# )
|
||||
# return res
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2017-2020 Akretion France
|
||||
# Copyright 2017-2022 Akretion France
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -22,18 +22,6 @@
|
||||
<button name="button_cancel" type="object" position="attributes">
|
||||
<attribute name="confirm">Are you sure you want to cancel this purchase order?</attribute>
|
||||
</button>
|
||||
<!-- 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 move it
|
||||
from the top of the view to the second tab -->
|
||||
<field name="origin" position="replace"/>
|
||||
<field name="date_approve" position="after">
|
||||
<field name="origin"/>
|
||||
</field>
|
||||
<!-- Remove once this PR is merged https://github.com/odoo/odoo/pull/35073 -->
|
||||
<xpath expr="//field[@name='order_line']/form//field[@name='analytic_tag_ids']" position="attributes">
|
||||
<attribute name="groups">analytic.group_analytic_tags</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="after">
|
||||
<field name="product_supplier_code" optional="hide"/>
|
||||
<field name="product_barcode" optional="hide"/>
|
||||
@@ -65,7 +53,7 @@
|
||||
</group>
|
||||
<field name="name" position="attributes">
|
||||
<attribute name="string">Reference, Origin or Vendor Reference</attribute>
|
||||
<attribute name="filter_domain">['|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('partner_ref', 'ilike', self)]</attribute>
|
||||
<attribute name="filter_domain">['|', '|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('partner_ref', 'ilike', self), ('partner_id', 'child_of', self)]</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -104,7 +92,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- 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, 'quotation_only': True}</field>
|
||||
@@ -116,20 +103,15 @@
|
||||
<field name="model">purchase.order.line</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_line_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="replace"/>
|
||||
<field name="product_id" position="after">
|
||||
<field name="name"/>
|
||||
<field name="name" position="move"/>
|
||||
</field>
|
||||
<field name="product_qty" position="after">
|
||||
<field name="qty_received"/>
|
||||
<field name="qty_invoiced"/>
|
||||
</field>
|
||||
<field name="price_unit" position="replace"/>
|
||||
<field name="product_uom" position="after">
|
||||
<field name="price_unit"/>
|
||||
</field>
|
||||
<field name="product_qty" position="before">
|
||||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||
<field name="price_unit" position="move"/>
|
||||
</field>
|
||||
<field name="date_planned" position="after">
|
||||
<field name="state"/>
|
||||
@@ -137,18 +119,4 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="purchase_order_line_search" model="ir.ui.view">
|
||||
<field name="name">usability.purchase.order.line.search</field>
|
||||
<field name="model">purchase.order.line</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_line_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<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'}" groups="analytic.group_analytic_accounting"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2014-2020 Akretion (http://www.akretion.com/)
|
||||
Copyright 2014-2022 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).
|
||||
-->
|
||||
@@ -11,36 +11,4 @@
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user