[IMP] pre-commit: first run on whole repo

This commit is contained in:
Kevin Khao
2021-11-26 18:54:38 +03:00
parent a04b8980e1
commit 167aefee13
289 changed files with 6020 additions and 4170 deletions

View File

@@ -3,17 +3,17 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Purchase Usability',
'version': '14.0.1.0.0',
'category': 'Purchases',
'license': 'AGPL-3',
'summary': 'Usability improvements on purchase module',
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['purchase'],
'data': [
'views/purchase_order.xml',
'views/purchase_report.xml',
],
'installable': True,
"name": "Purchase Usability",
"version": "14.0.1.0.0",
"category": "Purchases",
"license": "AGPL-3",
"summary": "Usability improvements on purchase module",
"author": "Akretion",
"website": "https://github.com/OCA/odoo-usability",
"depends": ["purchase"],
"data": [
"views/purchase_order.xml",
"views/purchase_report.xml",
],
"installable": True,
}

View File

@@ -6,7 +6,7 @@ from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
_inherit = "product.template"
purchase_method = fields.Selection(tracking=True)
purchase_line_warn = fields.Selection(tracking=True)

View File

@@ -7,7 +7,7 @@ from odoo.tools.misc import formatLang
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
_inherit = "purchase.order"
dest_address_id = fields.Many2one(tracking=True)
currency_id = fields.Many2one(tracking=True)
@@ -17,24 +17,26 @@ class PurchaseOrder(models.Model):
# 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')
"res.partner", compute="_compute_delivery_partner_id"
)
@api.depends('dest_address_id')
@api.depends("dest_address_id")
def _compute_delivery_partner_id(self):
for order in self:
order.delivery_partner_id = order.dest_address_id
# Re-write native name_get() to use amount_untaxed instead of amount_total
@api.depends('name', 'partner_ref')
@api.depends("name", "partner_ref")
def name_get(self):
result = []
for po in self:
name = po.name
if po.partner_ref:
name += ' (' + po.partner_ref + ')'
if self.env.context.get('show_total_amount') and po.amount_untaxed:
name += ': ' + formatLang(
self.env, po.amount_untaxed, currency_obj=po.currency_id)
name += " (" + po.partner_ref + ")"
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
@@ -45,18 +47,18 @@ class PurchaseOrder(models.Model):
has_sections = False
subtotal = 0.0
for line in self.order_line:
if line.display_type == 'line_section':
if line.display_type == "line_section":
# insert line
if has_sections:
res.append({'subtotal': subtotal})
res.append({"subtotal": subtotal})
subtotal = 0.0 # reset counter
has_sections = True
else:
if not line.display_type:
subtotal += line.price_subtotal
res.append({'line': line})
res.append({"line": line})
if has_sections: # insert last subtotal line
res.append({'subtotal': subtotal})
res.append({"subtotal": subtotal})
# res:
# [
# {'line': sale_order_line(1) with display_type=='line_section'},
@@ -69,7 +71,9 @@ class PurchaseOrder(models.Model):
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
_inherit = "purchase.order.line"
# for optional display in tree view
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
product_barcode = fields.Char(
related="product_id.barcode", string="Product Barcode"
)

View File

@@ -6,6 +6,6 @@ from odoo import fields, models
class ResPartner(models.Model):
_inherit = 'res.partner'
_inherit = "res.partner"
purchase_warn = fields.Selection(tracking=True)

View File

@@ -1,41 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<?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_order_form" model="ir.ui.view">
<field name="name">usability.purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<button name="action_rfq_send" states="purchase" position="after">
<button name="%(purchase.action_report_purchase_order)d" states="purchase,done" string="Print" type="action"/>
<button
name="%(purchase.action_report_purchase_order)d"
states="purchase,done"
string="Print"
type="action"
/>
</button>
<field name="fiscal_position_id" position="attributes">
<attribute name="widget">selection</attribute>
</field>
<button name="button_cancel" type="object" position="attributes">
<attribute name="confirm">Are you sure you want to cancel this purchase order?</attribute>
<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="origin" position="replace" />
<field name="date_approve" position="after">
<field name="origin"/>
<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">
<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_barcode" optional="hide"/>
<xpath
expr="//field[@name='order_line']/tree//field[@name='product_id']"
position="after"
>
<field name="product_barcode" optional="hide" />
</xpath>
</field>
</record>
@@ -43,7 +55,7 @@
<record id="purchase_order_tree" model="ir.ui.view">
<field name="name">usability.purchase.order.tree</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_tree"/>
<field name="inherit_id" ref="purchase.purchase_order_tree" />
<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,
@@ -57,14 +69,20 @@
<record id="view_purchase_order_filter" model="ir.ui.view">
<field name="name">usability.purchase.order.tree</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.view_purchase_order_filter"/>
<field name="inherit_id" ref="purchase.view_purchase_order_filter" />
<field name="arch" type="xml">
<group expand="0" position="inside">
<filter string="Billing Status" name="invoice_status_groupby" context="{'group_by': 'invoice_status'}"/>
<filter
string="Billing Status"
name="invoice_status_groupby"
context="{'group_by': 'invoice_status'}"
/>
</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)]</attribute>
</field>
</field>
</record>
@@ -73,10 +91,10 @@
<record id="purchase_order_pivot" model="ir.ui.view">
<field name="name">usability.purchase.order.pivot</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_pivot"/>
<field name="inherit_id" ref="purchase.purchase_order_pivot" />
<field name="arch" type="xml">
<field name="amount_total" type="measure" position="replace">
<field name="amount_untaxed" type="measure"/>
<field name="amount_untaxed" type="measure" />
</field>
</field>
</record>
@@ -84,10 +102,10 @@
<record id="purchase_order_graph" model="ir.ui.view">
<field name="name">usability.purchase.order.graph</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_graph"/>
<field name="inherit_id" ref="purchase.purchase_order_graph" />
<field name="arch" type="xml">
<field name="amount_total" type="measure" position="replace">
<field name="amount_untaxed" type="measure"/>
<field name="amount_untaxed" type="measure" />
</field>
</field>
</record>
@@ -95,10 +113,10 @@
<record id="purchase_order_calendar" model="ir.ui.view">
<field name="name">usability.purchase.order.calendar</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_calendar"/>
<field name="inherit_id" ref="purchase.purchase_order_calendar" />
<field name="arch" type="xml">
<field name="amount_total" position="replace">
<field name="amount_untaxed" widget="monetary"/>
<field name="amount_untaxed" widget="monetary" />
</field>
</field>
</record>
@@ -113,25 +131,28 @@
<record id="purchase_order_line_tree" model="ir.ui.view">
<field name="name">usability.purchase.order.line.tree</field>
<field name="model">purchase.order.line</field>
<field name="inherit_id" ref="purchase.purchase_order_line_tree"/>
<field name="inherit_id" ref="purchase.purchase_order_line_tree" />
<field name="arch" type="xml">
<field name="name" position="replace"/>
<field name="name" position="replace" />
<field name="product_id" position="after">
<field name="name"/>
<field name="name" />
</field>
<field name="product_qty" position="after">
<field name="qty_received"/>
<field name="qty_invoiced"/>
<field name="qty_received" />
<field name="qty_invoiced" />
</field>
<field name="price_unit" position="replace"/>
<field name="price_unit" position="replace" />
<field name="product_uom" position="after">
<field name="price_unit"/>
<field name="price_unit" />
</field>
<field name="product_qty" position="before">
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
<field
name="account_analytic_id"
groups="analytic.group_analytic_accounting"
/>
</field>
<field name="date_planned" position="after">
<field name="state"/>
<field name="state" />
</field>
</field>
</record>
@@ -139,13 +160,21 @@
<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="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
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"/>
<filter
string="Analytic Account"
name="account_analytic_groupby"
context="{'group_by': 'account_analytic_id'}"
groups="analytic.group_analytic_accounting"
/>
</group>
</field>
</record>

View File

@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<?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 -->
<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="inherit_id" ref="purchase.view_purchase_order_pivot" />
<field name="arch" type="xml">
<pivot position="attributes">
<attribute name="disable_linking"></attribute>
<attribute name="disable_linking" />
</pivot>
</field>
</record>
@@ -26,19 +27,22 @@
<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"/>
<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>