[MIG] sale_usability to v16

This commit is contained in:
Alexis de Lattre
2022-10-30 23:44:09 +01:00
parent 5c14e3199e
commit fbdf814cb0
14 changed files with 69 additions and 146 deletions

View File

@@ -1,10 +1,10 @@
# Copyright 2014-2020 Akretion (http://www.akretion.com) # Copyright 2014-2022 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Sale Usability', 'name': 'Sale Usability',
'version': '14.0.1.0.0', 'version': '16.0.1.0.0',
'category': 'Sales', 'category': 'Sales',
'license': 'AGPL-3', 'license': 'AGPL-3',
'summary': 'Usability improvements on sale module', 'summary': 'Usability improvements on sale module',
@@ -12,8 +12,8 @@
'website': 'http://www.akretion.com', 'website': 'http://www.akretion.com',
'depends': [ 'depends': [
'sale', 'sale',
'account_usability', # for company view # 'account_usability', # for company view
'base_view_inheritance_extension', # 'base_view_inheritance_extension',
], ],
'data': [ 'data': [
'views/sale_order.xml', 'views/sale_order.xml',
@@ -21,10 +21,10 @@
'views/sale_report.xml', 'views/sale_report.xml',
'views/product_pricelist_item.xml', 'views/product_pricelist_item.xml',
'views/account_move.xml', 'views/account_move.xml',
'views/res_company.xml', # 'views/res_company.xml', TODO uncomment once account_usa is ported
"views/res_partner.xml", "views/res_partner.xml",
'wizards/sale_invoice_discount_all_lines_view.xml', 'wizards/sale_invoice_discount_all_lines_view.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
], ],
'installable': False, 'installable': True,
} }

View File

@@ -1,46 +1,14 @@
# Copyright (C) 2015-2019 Akretion (http://www.akretion.com) # Copyright 2015-2022 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models from odoo import models
from collections import OrderedDict from collections import OrderedDict
class AccountMove(models.Model): class AccountMove(models.Model):
_inherit = 'account.move' _inherit = 'account.move'
# sale_ids is kind of the symetric field of invoice_ids on sale.order
sale_ids = fields.Many2many(
'sale.order', string='Sale Orders', compute="_compute_sale_ids")
sale_count = fields.Integer(
string='Sale Order Count', compute='_compute_sale_ids')
@api.depends('invoice_line_ids.sale_line_ids')
def _compute_sale_ids(self):
for invoice in self:
if invoice.move_type == 'out_invoice':
sales = invoice.invoice_line_ids.mapped('sale_line_ids').\
mapped('order_id')
invoice.sale_ids = sales.ids
invoice.sale_count = len(sales.ids)
else:
invoice.sale_ids = []
invoice.sale_count = 0
def show_sale_orders(self):
self.ensure_one()
action = self.env.ref('sale.action_orders').sudo().read()[0]
sales = self.sale_ids
if len(sales) > 1:
action['domain'] = [('id', 'in', sales.ids)]
else:
action.update({
'res_id': sales.id,
'view_mode': 'form,tree,kanban,calendar,pivot,graph,activity',
'views': False,
})
return action
def py3o_lines_layout_groupby_order(self, subtotal=True): def py3o_lines_layout_groupby_order(self, subtotal=True):
# This method is an alternative to the method py3o_lines_layout() # This method is an alternative to the method py3o_lines_layout()
# defined above: you just have to change the call in the invoice # defined above: you just have to change the call in the invoice

View File

@@ -1,4 +1,4 @@
# Copyright 2017-2019 Akretion France # Copyright 2017-2022 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -12,3 +12,4 @@ class ProductTemplate(models.Model):
expense_policy = fields.Selection(tracking=True) expense_policy = fields.Selection(tracking=True)
invoice_policy = fields.Selection(tracking=True) invoice_policy = fields.Selection(tracking=True)
sale_line_warn = fields.Selection(tracking=True) sale_line_warn = fields.Selection(tracking=True)
expense_policy = fields.Selection(tracking=True)

View File

@@ -1,4 +1,4 @@
# Copyright 2021 Akretion France (https://akretion.com/) # Copyright 2021-2022 Akretion France (https://akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@@ -1,4 +1,4 @@
# Copyright 2017-2020 Akretion France (https://akretion.com/) # Copyright 2017-2022 Akretion France (https://akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@@ -2,9 +2,8 @@
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _ from odoo import api, fields, models
from odoo.tools import float_is_zero, float_compare from odoo.tools import float_is_zero
from odoo.tools.misc import formatLang
class SaleOrder(models.Model): class SaleOrder(models.Model):
@@ -16,7 +15,6 @@ class SaleOrder(models.Model):
amount_tax = fields.Monetary(tracking=True) amount_tax = fields.Monetary(tracking=True)
partner_shipping_id = fields.Many2one(tracking=True) partner_shipping_id = fields.Many2one(tracking=True)
partner_invoice_id = fields.Many2one(tracking=True) partner_invoice_id = fields.Many2one(tracking=True)
pricelist_id = fields.Many2one(tracking=True)
payment_term_id = fields.Many2one(tracking=True) payment_term_id = fields.Many2one(tracking=True)
fiscal_position_id = fields.Many2one(tracking=True) fiscal_position_id = fields.Many2one(tracking=True)
# for reports # for reports
@@ -97,33 +95,33 @@ class SaleOrderLine(models.Model):
product_barcode = fields.Char( product_barcode = fields.Char(
related='product_id.barcode', string="Product Barcode") related='product_id.barcode', string="Product Barcode")
@api.onchange('product_uom', 'product_uom_qty') # @api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self): # def product_uom_change(self):
# When the user has manually set a custom price # When the user has manually set a custom price
# he is often upset when Odoo changes it when he changes the qty # he is often upset when Odoo changes it when he changes the qty
# So we add a warning in which we recall the old price. # So we add a warning in which we recall the old price.
res = {} # res = {}
old_price = self.price_unit # old_price = self.price_unit
super().product_uom_change() # super().product_uom_change()
new_price = self.price_unit # new_price = self.price_unit
prec = self.env['decimal.precision'].precision_get('Product Price') # prec = self.env['decimal.precision'].precision_get('Product Price')
if float_compare(old_price, new_price, precision_digits=prec): # if float_compare(old_price, new_price, precision_digits=prec):
pricelist = self.order_id.pricelist_id # pricelist = self.order_id.pricelist_id
res['warning'] = { # res['warning'] = {
'title': _('Price updated'), # 'title': _('Price updated'),
'message': _( # 'message': _(
"Due to the update of the ordered quantity on line '%s', " # "Due to the update of the ordered quantity on line '%s', "
"the price has been updated according to pricelist '%s'.\n" # "the price has been updated according to pricelist '%s'.\n"
"Old price: %s\n" # "Old price: %s\n"
"New price: %s") % ( # "New price: %s") % (
self.name, # self.name,
pricelist.display_name, # pricelist.display_name,
formatLang( # formatLang(
self.env, old_price, currency_obj=pricelist.currency_id), # self.env, old_price, currency_obj=pricelist.currency_id),
formatLang( # formatLang(
self.env, new_price, currency_obj=pricelist.currency_id)) # self.env, new_price, currency_obj=pricelist.currency_id))
} # }
return res # return res
def get_sale_order_line_multiline_description_sale(self, product): def get_sale_order_line_multiline_description_sale(self, product):
# This is useful when you want to have the product code in a dedicated # This is useful when you want to have the product code in a dedicated

View File

@@ -1,14 +1,12 @@
This modules adds the following functions: This modules adds the following functions:
* Display amount untaxed in tree view * Display amount untaxed in tree view
* Add sale_ids and sale_count on Invoice
* Methods for py3o sale reports * Methods for py3o sale reports
* Add tracking on partner warning fields * Add tracking on partner warning fields
* Add tracking on product fields * Add tracking on product fields
* Add tracking on Sale Order fields * Add tracking on Sale Order fields
* Add menu for Pricelist Items * Add menu for Pricelist Items
* Add `has_discount` field on Sale Order * Add `has_discount` field on Sale Order
* Restore drill-through on sale and invoice reports
* Move client_order_ref from the second tab to the top * Move client_order_ref from the second tab to the top
* Protect Cancel button with a confirmation pop-up * Protect Cancel button with a confirmation pop-up
* Remove Sale Orders from Quotations menu * Remove Sale Orders from Quotations menu

View File

@@ -1,37 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2019-2020 Akretion France (http://www.akretion.com/) Copyright 2019-2022 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->
<odoo> <odoo>
<record id="account_invoice_form" model="ir.ui.view">
<field name="name">sale_usability.customer.invoice.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="sale.account_invoice_form" />
<field name="groups_id" eval="[(4, ref('sales_team.group_sale_manager'))]" />
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button
name="show_sale_orders"
type="object"
class="oe_stat_button"
icon="fa-pencil-square-o"
attrs="{'invisible': [('sale_count', '=', 0)]}">
<field name="sale_count" widget="statinfo" string="Sale Orders" />
</button>
</div>
</field>
</record>
<record id="view_move_form" model="ir.ui.view"> <record id="view_move_form" model="ir.ui.view">
<field name="name">sale_usability.account.move.form</field> <field name="name">sale_usability.account.move.form</field>
<field name="model">account.move</field> <field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/> <field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/form//field[@name='analytic_account_id']" position="after"> <xpath expr="//field[@name='invoice_line_ids']/form//field[@name='analytic_distribution']" position="after">
<field name="sale_line_ids" widget="many2many_tags" attrs="{'invisible': [('sale_line_ids', '=', [])]}"/> <field name="sale_line_ids" widget="many2many_tags" attrs="{'invisible': [('sale_line_ids', '=', [])]}"/>
</xpath> </xpath>
</field> </field>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
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> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->
@@ -11,6 +11,6 @@
similar to what we have in Stock > Configuration > Products similar to what we have in Stock > Configuration > Products
because we need this menu entry even if the 'stock' module is not installed --> because we need this menu entry even if the 'stock' module is not installed -->
<menuitem id="product_category_sale_menu" action="product.product_category_action_form" <menuitem id="product_category_sale_menu" action="product.product_category_action_form"
parent="sale.prod_config_main" sequence="10"/> parent="sale.prod_config_main" sequence="5"/>
</odoo> </odoo>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2017-2020 Akretion France (http://www.akretion.com/) Copyright 2017-2022 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2021 Akretion (http://www.akretion.com/) Copyright 2021-2022 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->

View File

@@ -6,7 +6,7 @@
<field name="inherit_id" ref="sales_team.res_partner_view_team" /> <field name="inherit_id" ref="sales_team.res_partner_view_team" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- team_id should be visible in no developper mode --> <!-- team_id should be visible in no developper mode -->
<field name="team_id" position="attributes"> <field name="team_id" groups="base.group_no_one" position="attributes">
<attribute name="groups"/> <attribute name="groups"/>
</field> </field>
</field> </field>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2015-2019 Akretion France (http://www.akretion.com/) Copyright 2015-2022 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->
@@ -15,16 +15,16 @@
<field name="fiscal_position_id" position="attributes"> <field name="fiscal_position_id" position="attributes">
<attribute name="widget">selection</attribute> <attribute name="widget">selection</attribute>
</field> </field>
<!-- TODO uncomment when base_extended_view is avail on v16
<field name="partner_shipping_id" position="attributes"> <field name="partner_shipping_id" position="attributes">
<attribute name="context" operation="python_dict" key="show_address">1</attribute> <attribute name="context" operation="python_dict" key="show_address">1</attribute>
</field> </field> -->
<button name="action_cancel" type="object" position="attributes"> <button name="action_cancel" type="object" position="attributes">
<attribute name="confirm">Are you sure you want to cancel this sale order?</attribute> <attribute name="confirm">Are you sure you want to cancel this sale order?</attribute>
</button> </button>
<!-- client_order_ref is an important field, so we should put it in the top like in v8, not hidden in the second tab --> <!-- client_order_ref is an important field, so we should put it in the top like in v8, not hidden in the second tab -->
<field name="client_order_ref" position="replace"/>
<field name="date_order" position="after"> <field name="date_order" position="after">
<field name="client_order_ref"/> <field name="client_order_ref" position="move"/>
</field> </field>
<button name="action_quotation_send" states="sent,sale" position="after"> <button name="action_quotation_send" states="sent,sale" position="after">
<button name="%(sale.action_report_saleorder)d" type="action" string="Print" states="draft,sent,sale,done"/> <button name="%(sale.action_report_saleorder)d" type="action" string="Print" states="draft,sent,sale,done"/>
@@ -35,6 +35,17 @@
<button name="action_quotation_send" attrs="{'invisible': ['|', ('state', '=', 'draft'), ('invoice_count','&gt;=',1)]}" position="before"> <button name="action_quotation_send" attrs="{'invisible': ['|', ('state', '=', 'draft'), ('invoice_count','&gt;=',1)]}" position="before">
<button name="action_quotation_send" type="object" string="Send Order Acknowledgement" attrs="{'invisible': ['|', ('state', 'not in', ('sale', 'done')), ('invoice_count','&gt;=',1)]}"/> <button name="action_quotation_send" type="object" string="Send Order Acknowledgement" attrs="{'invisible': ['|', ('state', 'not in', ('sale', 'done')), ('invoice_count','&gt;=',1)]}"/>
</button> </button>
<xpath expr="//field[@name='order_line']/tree/field[@name='product_uom_qty']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
<!-- it doesn't work... I don't know why ! -->
<xpath expr="//field[@name='order_line']/tree/field[@name='qty_delivered']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
<!-- it doesn't work... I don't know why ! -->
<xpath expr="//field[@name='order_line']/tree/field[@name='qty_invoiced']" position="attributes">
<attribute name="sum">1</attribute>
</xpath>
</field> </field>
</record> </record>
@@ -62,6 +73,7 @@
</field> </field>
<field name="state" position="attributes"> <field name="state" position="attributes">
<attribute name="invisible">0</attribute> <attribute name="invisible">0</attribute>
<attribute name="optional">hide</attribute>
</field> </field>
<field name="partner_id" position="after"> <field name="partner_id" position="after">
<field name="client_order_ref" optional="show"/> <field name="client_order_ref" optional="show"/>
@@ -94,10 +106,6 @@ https://github.com/odoo/odoo/commit/c1e5ab9b1331c3cb7dc2232bf78952bdb40ad939 -->
<field name="domain">[('state', 'in', ('draft', 'sent', 'cancel'))]</field> <field name="domain">[('state', 'in', ('draft', 'sent', 'cancel'))]</field>
</record> </record>
<record id="sale.action_quotations_salesteams" model="ir.actions.act_window">
<field name="domain">[('state', 'in', ('draft', 'sent', 'cancel'))]</field>
</record>
<record id="view_sales_order_line_filter" model="ir.ui.view"> <record id="view_sales_order_line_filter" model="ir.ui.view">
<field name="name">usability.sale.order.line.search</field> <field name="name">usability.sale.order.line.search</field>
<field name="model">sale.order.line</field> <field name="model">sale.order.line</field>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2018-2020 Akretion (http://www.akretion.com/) Copyright 2018-2022 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->
@@ -8,48 +8,17 @@
<odoo> <odoo>
<record id="sale_report_tree" model="ir.ui.view"> <record id="sale_report_view_tree" model="ir.ui.view">
<field name="name">usability.sale.report.tree</field> <field name="name">usability.sale.report.tree</field>
<field name="model">sale.report</field> <field name="model">sale.report</field>
<field name="arch" type="xml"> <field name="inherit_id" ref="sale.sale_report_view_tree"/>
<tree string="Sales Analysis">
<field name="name"/>
<field name="date"/>
<field name="commercial_partner_id"/>
<field name="user_id"/>
<field name="product_id"/>
<field name="product_uom_qty" sum="1"/>
<field name="qty_delivered" sum="1"/>
<field name="qty_to_invoice" sum="1"/>
<field name="product_uom" groups="uom.group_uom"/>
<field name="price_subtotal" sum="1"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="sale.action_order_report_all" model="ir.actions.act_window">
<field name="context">{'search_default_Sales': 1}</field> <!-- Remove group_by_no_leaf, which breaks tree view -->
</record>
<record id="view_order_product_pivot" model="ir.ui.view">
<field name="name">usability.sale.report.pivot</field>
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_pivot"/>
<field name="arch" type="xml">
<pivot position="attributes">
<attribute name="disable_linking"></attribute>
</pivot>
</field>
</record>
<record id="view_order_product_search" model="ir.ui.view">
<field name="name">usability.sale.report.search</field>
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_search"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="user_id" position="after"> <field name="user_id" position="after">
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/> <field name="product_id" optional="show"/>
<field name="product_uom_qty" sum="1" optional="show"/>
<field name="qty_delivered" sum="1" optional="hide"/>
<field name="qty_to_invoice" sum="1" optional="hide"/>
<field name="product_uom" groups="uom.group_uom" optional="show"/>
</field> </field>
</field> </field>
</record> </record>