-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] stock_price_br and CST-level creditable taxes
- Loading branch information
1 parent
a5982d6
commit 08e4cd1
Showing
9 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# Copyright (C) 2015 Renato Lima - Akretion | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import cst | ||
from . import res_company | ||
from . import stock_rule | ||
from . import stock_picking_type | ||
from . import stock_picking | ||
from . import stock_price_mixin | ||
from . import stock_move | ||
from . import procurement_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (C) 2024 - Diego Paradeda - KMEE | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class CST(models.Model): | ||
_inherit = "l10n_br_fiscal.cst" | ||
|
||
creditable_tax = fields.Boolean( | ||
string="Creditable Tax?", | ||
default=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (C) 2024 Diego Paradeda - KMEE <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.float_utils import float_round | ||
|
||
from odoo.addons.l10n_br_fiscal.constants.fiscal import TAX_DOMAIN_ICMS_SN | ||
|
||
|
||
class StockPriceMixin(models.AbstractModel): | ||
_name = "l10n_br_stock_account.stock.price.mixin" | ||
_description = "Stock Price Mixin" | ||
|
||
def _default_valuation_stock_price(self): | ||
""" | ||
Método para chavear o custo médio dos produtos entre: | ||
- líquido de impostos | ||
- com impostos (padrão do Odoo). | ||
TODO: Posicionar o campo para o usuário poder interagir com esse chaveamento | ||
a nível de company | ||
""" | ||
return True | ||
|
||
valuation_via_stock_price = fields.Boolean( | ||
string="Valuation Via Stock Price", | ||
default=_default_valuation_stock_price, | ||
help="Determina se o valor utilizado no custeamento automático será padrão do" | ||
" Odoo ou com base no campo stock_price_br.\n\n" | ||
" * Usar True para valor de estoque líquido (sem imposto)", | ||
) | ||
|
||
currency_id = fields.Many2one( | ||
comodel_name="res.currency", | ||
string="Currency", | ||
default=lambda self: self.env.ref("base.BRL"), | ||
) | ||
|
||
stock_price_br = fields.Monetary( | ||
string="Stock Price", compute="_compute_stock_price_br" | ||
) | ||
|
||
@api.depends("amount_total", "fiscal_tax_ids", "valuation_via_stock_price") | ||
def _compute_stock_price_br(self): | ||
"""Subtract creditable taxes from stock price.""" | ||
for record in self: | ||
record.stock_price_br = 0 | ||
|
||
if not hasattr(record, "product_uom_qty"): | ||
continue | ||
|
||
if record.fiscal_operation_line_id and record.product_uom_qty: | ||
price = record.amount_total | ||
|
||
if not record.valuation_via_stock_price: | ||
continue | ||
|
||
for tax in record.fiscal_tax_ids: | ||
if hasattr(record, "%s_tax_id" % (tax.tax_domain,)): | ||
if hasattr(record, "%s_cst_id" % (tax.tax_domain,)): | ||
cst_id = getattr(record, "%s_cst_id" % (tax.tax_domain,)) | ||
else: | ||
# Para tax to tipo icmssn o CST fica no campo icms_cst_id | ||
if tax.tax_domain in TAX_DOMAIN_ICMS_SN: | ||
cst_id = record.icms_cst_id | ||
|
||
if cst_id and cst_id.creditable_tax: | ||
if not hasattr(record, "%s_value" % (tax.tax_domain)): | ||
continue | ||
price -= getattr(record, "%s_value" % (tax.tax_domain)) | ||
|
||
price_precision = self.env["decimal.precision"].precision_get( | ||
"Product Price" | ||
) | ||
record.stock_price_br = float_round( | ||
(price / record.product_uom_qty), precision_digits=price_precision | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,11 @@ | |
|
||
/* | ||
:Author: David Goodger ([email protected]) | ||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ | ||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ | ||
:Copyright: This stylesheet has been placed in the public domain. | ||
Default cascading style sheet for the HTML output of Docutils. | ||
Despite the name, some widely supported CSS2 features are used. | ||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to | ||
customize this style sheet. | ||
|
@@ -274,7 +275,7 @@ | |
margin-left: 2em ; | ||
margin-right: 2em } | ||
|
||
pre.code .ln { color: grey; } /* line numbers */ | ||
pre.code .ln { color: gray; } /* line numbers */ | ||
pre.code, code { background-color: #eeeeee } | ||
pre.code .comment, code .comment { color: #5C6576 } | ||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } | ||
|
@@ -300,7 +301,7 @@ | |
span.pre { | ||
white-space: pre } | ||
|
||
span.problematic { | ||
span.problematic, pre.problematic { | ||
color: red } | ||
|
||
span.section-subtitle { | ||
|
@@ -464,7 +465,9 @@ <h2><a class="toc-backref" href="#toc-entry-11">Other credits</a></h2> | |
<div class="section" id="maintainers"> | ||
<h2><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h2> | ||
<p>This module is maintained by the OCA.</p> | ||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> | ||
<a class="reference external image-reference" href="https://odoo-community.org"> | ||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /> | ||
</a> | ||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use.</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<odoo> | ||
|
||
<record id="cst_form_inherit" model="ir.ui.view"> | ||
<field name="name">l10n_br_fiscal.cst.form</field> | ||
<field name="model">l10n_br_fiscal.cst</field> | ||
<field name="inherit_id" ref="l10n_br_fiscal.cst_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="tax_group_id" position="after"> | ||
<field name="creditable_tax" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters