[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,15 +3,15 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Category Tax',
'version': '14.0.1.0.0',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'summary': 'Adds sale and purchase taxes on product category',
'description': "",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['account'],
'data': ['product_view.xml'],
'installable': True,
"name": "Product Category Tax",
"version": "14.0.1.0.0",
"category": "Accounting & Finance",
"license": "AGPL-3",
"summary": "Adds sale and purchase taxes on product category",
"description": "",
"author": "Akretion",
"website": "https://github.com/OCA/odoo-usability",
"depends": ["account"],
"data": ["product_view.xml"],
"installable": True,
}

View File

@@ -2,19 +2,20 @@
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# 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.exceptions import ValidationError
class ProductCategTaxMixin(models.AbstractModel):
_name = 'product.categ.tax.mixin'
_description = 'Common code for taxes on product categories'
_name = "product.categ.tax.mixin"
_description = "Common code for taxes on product categories"
@api.onchange('categ_id')
@api.onchange("categ_id")
def onchange_categ_id(self):
if self.categ_id:
self.taxes_id, self.supplier_taxes_id = (
self.apply_tax_from_category(self.categ_id))
self.taxes_id, self.supplier_taxes_id = self.apply_tax_from_category(
self.categ_id
)
@api.model
def apply_tax_from_category(self, categ):
@@ -24,15 +25,15 @@ class ProductCategTaxMixin(models.AbstractModel):
# of replacing the taxes... and I want to REPLACE the taxes
# So I have to use the awful syntax (6, 0, [IDs])
# values are sent to ('taxes_id' and 'supplier_taxes_id')
return ([(6, 0, categ.sale_tax_ids.ids)],
[(6, 0, categ.purchase_tax_ids.ids)])
return ([(6, 0, categ.sale_tax_ids.ids)], [(6, 0, categ.purchase_tax_ids.ids)])
@api.model
def write_or_create(self, vals):
if vals.get('categ_id'):
categ = self.env['product.category'].browse(vals['categ_id'])
vals['taxes_id'], vals['supplier_taxes_id'] =\
self.apply_tax_from_category(categ)
if vals.get("categ_id"):
categ = self.env["product.category"].browse(vals["categ_id"])
vals["taxes_id"], vals["supplier_taxes_id"] = self.apply_tax_from_category(
categ
)
@api.model
def create(self, vals):
@@ -45,42 +46,56 @@ class ProductCategTaxMixin(models.AbstractModel):
class ProductTemplate(models.Model):
_inherit = ['product.template', 'product.categ.tax.mixin']
_name = 'product.template'
_inherit = ["product.template", "product.categ.tax.mixin"]
_name = "product.template"
@api.constrains('taxes_id', 'supplier_taxes_id')
@api.constrains("taxes_id", "supplier_taxes_id")
def _check_tax_categ(self):
# self.name != 'Pay Debt' is a stupid hack to avoid blocking the
# installation of the module 'pos_debt_notebook'
for pt in self:
if pt.categ_id: # and self.name != 'Pay Debt':
if pt.categ_id: # and self.name != 'Pay Debt':
if pt.categ_id.sale_tax_ids.ids != pt.taxes_id.ids:
raise ValidationError(_(
"The sale taxes configured on the product '%s' "
"are not the same as the sale taxes configured "
"on it's related internal category '%s'.")
% (pt.display_name, pt.categ_id.display_name))
if (
pt.categ_id.purchase_tax_ids.ids !=
pt.supplier_taxes_id.ids):
raise ValidationError(_(
"The purchase taxes configured on the product '%s' "
"are not the same as the purchase taxes configured "
"on it's related internal category '%s'.")
% (pt.display_name, pt.categ_id.display_name))
raise ValidationError(
_(
"The sale taxes configured on the product '%s' "
"are not the same as the sale taxes configured "
"on it's related internal category '%s'."
)
% (pt.display_name, pt.categ_id.display_name)
)
if pt.categ_id.purchase_tax_ids.ids != pt.supplier_taxes_id.ids:
raise ValidationError(
_(
"The purchase taxes configured on the product '%s' "
"are not the same as the purchase taxes configured "
"on it's related internal category '%s'."
)
% (pt.display_name, pt.categ_id.display_name)
)
class ProductProduct(models.Model):
_inherit = ['product.product', 'product.categ.tax.mixin']
_name = 'product.product'
_inherit = ["product.product", "product.categ.tax.mixin"]
_name = "product.product"
class ProductCategory(models.Model):
_inherit = 'product.category'
_inherit = "product.category"
sale_tax_ids = fields.Many2many(
'account.tax', 'product_categ_sale_tax_rel', 'categ_id', 'tax_id',
string="Sale Taxes", domain=[('type_tax_use', '=', 'sale')])
"account.tax",
"product_categ_sale_tax_rel",
"categ_id",
"tax_id",
string="Sale Taxes",
domain=[("type_tax_use", "=", "sale")],
)
purchase_tax_ids = fields.Many2many(
'account.tax', 'product_categ_purchase_tax_rel', 'categ_id', 'tax_id',
string="Purchase Taxes", domain=[('type_tax_use', '=', 'purchase')])
"account.tax",
"product_categ_purchase_tax_rel",
"categ_id",
"tax_id",
string="Purchase Taxes",
domain=[("type_tax_use", "=", "purchase")],
)

View File

@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2015-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="view_category_property_form" model="ir.ui.view">
@@ -13,10 +12,18 @@
<field name="inherit_id" ref="account.view_category_property_form" />
<field name="arch" type="xml">
<field name="property_account_income_categ_id" position="after">
<field name="sale_tax_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field
name="sale_tax_ids"
widget="many2many_tags"
options="{'no_create': True}"
/>
</field>
<field name="property_account_expense_categ_id" position="after">
<field name="purchase_tax_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field
name="purchase_tax_ids"
widget="many2many_tags"
options="{'no_create': True}"
/>
</field>
</field>
</record>