Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] add tax_scope to account.product.fiscal.classification #439

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions account_product_fiscal_classification/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Account Product - Fiscal Classification
* Provides the possibility to the account manager to change incorrect
parameters massively;

* Possibility to use tax_scope to filter taxes with the same tax_scope

**Table of contents**

.. contents::
Expand Down Expand Up @@ -98,6 +100,7 @@ Contributors
* Sébastien BEAU <[email protected]>
* Pierrick Brun <[email protected]>
* Renato Lima <[email protected]>
* Thomas BONNERUE <[email protected]>

* Danimar RIBEIRO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def _default_company_id(self):

description = fields.Text()

tax_scope = fields.Selection(
[("service", "Services"), ("consu", "Goods")],
string="Tax Scope",
help="Restrict the use of taxes to a type of product.",
)

active = fields.Boolean(
default=True,
help="If unchecked, it will allow you to hide the Fiscal"
Expand Down Expand Up @@ -51,7 +57,10 @@ def _default_company_id(self):
column2="tax_id",
string="Purchase Taxes",
domain="""[
('type_tax_use', 'in', ['purchase', 'all'])]""",
('type_tax_use', 'in', ['purchase', 'all']),
'|',
('tax_scope', '=', False),
('tax_scope', '=', tax_scope)]""",
)

sale_tax_ids = fields.Many2many(
Expand All @@ -61,7 +70,10 @@ def _default_company_id(self):
column2="tax_id",
string="Sale Taxes",
domain="""[
('type_tax_use', 'in', ['sale', 'all'])]""",
('type_tax_use', 'in', ['sale', 'all']),
'|',
('tax_scope', '=', False),
('tax_scope', '=', tax_scope)]""",
)

usage_group_id = fields.Many2one(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class AccountProductFiscalClassificationTemplate(models.Model):

description = fields.Text()

tax_scope = fields.Selection(
[("service", "Services"), ("consu", "Goods")],
string="Tax Scope",
help="Restrict the use of taxes to a type of product.",
)

chart_template_id = fields.Many2one(
comodel_name="account.chart.template",
string="Chart Template",
Expand All @@ -34,6 +40,9 @@ class AccountProductFiscalClassificationTemplate(models.Model):
domain="["
"('type_tax_use', 'in', ['purchase', 'all']),"
"('chart_template_id', '=', chart_template_id),"
"'|',"
"('tax_scope', '=', False),"
"('tax_scope', '=', tax_scope),"
"]",
)

Expand All @@ -46,6 +55,9 @@ class AccountProductFiscalClassificationTemplate(models.Model):
domain="["
"('type_tax_use', 'in', ['sale', 'all']),"
"('chart_template_id', '=', chart_template_id),"
"'|',"
"('tax_scope', '=', False),"
"('tax_scope', '=', tax_scope),"
"]",
)

Expand Down
16 changes: 16 additions & 0 deletions account_product_fiscal_classification/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,32 @@ class ProductTemplate(models.Model):
_inherit = "product.template"

# Field Section
tax_scope_identification = fields.Char(
"type",
store=True,
compute="_compute_type_identification",
)

fiscal_classification_id = fields.Many2one(
comodel_name="account.product.fiscal.classification",
string="Fiscal Classification",
tracking=True,
domain="['|', ('tax_scope','=',None), ('tax_scope', '=', tax_scope_identification)]",
help="Specify the combination of taxes for this product."
" This field is required. If you dont find the correct Fiscal"
" Classification, Please create a new one or ask to your account"
" manager if you don't have the access right.",
)

# Depends Section
@api.depends("type")
def _compute_type_identification(self):
for product in self:
if product.type == "product":
product.tax_scope_identification = "consu"
else:
product.tax_scope_identification = product.type

Comment on lines +36 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add a new field on product.product. You could just base your domain on the product.type field ?

thanks !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the why i found to have the product.type "product" and "consu" on one label.
it may be to restrictive. but i don't found a other idea to get this.

Sorry, for the time. I misclick my answer

# Overload Section
@api.model
def create(self, vals):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
* Sébastien BEAU <[email protected]>
* Pierrick Brun <[email protected]>
* Renato Lima <[email protected]>
* Thomas BONNERUE <[email protected]>

* Danimar RIBEIRO
2 changes: 2 additions & 0 deletions account_product_fiscal_classification/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@

* Provides the possibility to the account manager to change incorrect
parameters massively;

* Possibility to use tax_scope to filter taxes with the same tax_scope;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
</group>
<separator string="Taxes" />
<group col="4" name="tax_ids">
<field name="tax_scope" />
<newline />
<field
name="purchase_tax_ids"
quick_create="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
</group>
<separator string="Taxes" />
<group name="tax_ids" col="4">
<field name="tax_scope" />
<newline />
<field
name="purchase_tax_ids"
quick_create="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<field name="inherit_id" ref="account.product_template_form_view" />
<field name="arch" type="xml">
<field name="taxes_id" position="before">
<field name="tax_scope_identification" invisible="1" />
<field
name="fiscal_classification_id"
colspan="2"
Expand Down
Loading