Skip to content

Commit 0919988

Browse files
committed
pre-commit automatic changes
1 parent 69e7d8e commit 0919988

23 files changed

+596
-617
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
exclude: |
66
(?x)
7-
7+
88
# We don't want to mess with tool-generated files
99
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
1010
# Library files can have extraneous formatting (even minimized)

l10n_ar_sale/.copier-answers.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ name: l10n_ar_sale
88
odoo_version: 18.0
99
pre_commit_ignore: []
1010
slug: ''
11-

l10n_ar_sale/.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
exclude: |
66
(?x)
7-
7+
88
# We don't want to mess with tool-generated files
99
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
1010
# Library files can have extraneous formatting (even minimized)

l10n_ar_sale/__manifest__.py

+22-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
{
2-
'name': 'Argentinian Sale Total Fields',
3-
'version': "18.0.1.0.0",
4-
'category': 'Localization/Argentina',
5-
'sequence': 14,
6-
'author': 'ADHOC SA',
7-
'website': 'www.adhoc.com.ar',
8-
'license': 'AGPL-3',
9-
'summary': '',
10-
'depends': [
11-
'sale',
12-
'l10n_ar_tax',
2+
"name": "Argentinian Sale Total Fields",
3+
"version": "18.0.1.0.0",
4+
"category": "Localization/Argentina",
5+
"sequence": 14,
6+
"author": "ADHOC SA",
7+
"website": "www.adhoc.com.ar",
8+
"license": "AGPL-3",
9+
"summary": "",
10+
"depends": [
11+
"sale",
12+
"l10n_ar_tax",
1313
],
14-
'external_dependencies': {
15-
},
16-
'data': [
17-
'security/invoice_sale_security.xml',
18-
'views/sale_view.xml',
19-
'views/l10n_ar_sale_templates.xml',
20-
'views/sale_report_templates.xml',
21-
'wizards/res_config_settings_view.xml',
14+
"external_dependencies": {},
15+
"data": [
16+
"security/invoice_sale_security.xml",
17+
"views/sale_view.xml",
18+
"views/l10n_ar_sale_templates.xml",
19+
"views/sale_report_templates.xml",
20+
"wizards/res_config_settings_view.xml",
2221
],
23-
'demo': [
24-
],
25-
'installable': True,
26-
'auto_install': False,
27-
'application': False,
22+
"demo": [],
23+
"installable": True,
24+
"auto_install": False,
25+
"application": False,
2826
}

l10n_ar_sale/models/sale_order.py

+30-23
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,87 @@
22
# For copyright and license notices, see __manifest__.py file in module root
33
# directory
44
##############################################################################
5-
from odoo import models, fields, api, _
6-
import json
75
import logging
6+
7+
from odoo import api, fields, models
8+
89
_logger = logging.getLogger(__name__)
910

1011

1112
class SaleOrder(models.Model):
1213
_inherit = "sale.order"
1314

1415
vat_discriminated = fields.Boolean(
15-
compute='_compute_vat_discriminated',
16+
compute="_compute_vat_discriminated",
1617
)
1718

1819
@api.depends(
19-
'partner_id.l10n_ar_afip_responsibility_type_id',
20-
'company_id.l10n_ar_company_requires_vat',)
20+
"partner_id.l10n_ar_afip_responsibility_type_id",
21+
"company_id.l10n_ar_company_requires_vat",
22+
)
2123
def _compute_vat_discriminated(self):
2224
for rec in self:
23-
rec.vat_discriminated = rec.company_id.l10n_ar_company_requires_vat and \
24-
rec.partner_id.l10n_ar_afip_responsibility_type_id.code in ['1'] or False
25+
rec.vat_discriminated = (
26+
rec.company_id.l10n_ar_company_requires_vat
27+
and rec.partner_id.l10n_ar_afip_responsibility_type_id.code in ["1"]
28+
or False
29+
)
2530

2631
def _compute_tax_totals(self):
2732
super()._compute_tax_totals()
2833
# discriminamos o no impuestos solo en pdf y portal. En backend siempre los mostramos. Para esto evaluamos:
2934
# commit_assetsbundle viene cuando sacamos pdf
3035
# portal_view lo mandamos cuando mostramos campo en portal
31-
report_or_portal_view = 'commit_assetsbundle' in self.env.context or 'from_portal_view' in self.env.context
36+
report_or_portal_view = "commit_assetsbundle" in self.env.context or "from_portal_view" in self.env.context
3237
if not report_or_portal_view:
3338
return
3439

3540
for order in self.filtered(lambda x: not x.vat_discriminated):
36-
tax_groups = order.order_line.mapped('tax_id.tax_group_id')
41+
tax_groups = order.order_line.mapped("tax_id.tax_group_id")
3742
if not tax_groups:
3843
continue
3944
to_remove_ids = tax_groups.filtered(lambda x: x.l10n_ar_vat_afip_code).ids
40-
tax_group_name = list(order.tax_totals['groups_by_subtotal'].keys())[0]
41-
tax_group_vals = order.tax_totals['groups_by_subtotal'].get(tax_group_name)
45+
tax_group_name = list(order.tax_totals["groups_by_subtotal"].keys())[0]
46+
tax_group_vals = order.tax_totals["groups_by_subtotal"].get(tax_group_name)
4247
# TODO revisar si es discriminar / no discrminar
43-
updated_tax_group_vals = list(filter(lambda x: x.get('tax_group_id') not in to_remove_ids, tax_group_vals))
48+
updated_tax_group_vals = list(filter(lambda x: x.get("tax_group_id") not in to_remove_ids, tax_group_vals))
4449
new_totals = order.tax_totals
45-
new_totals['groups_by_subtotal'].update({tax_group_name: updated_tax_group_vals})
50+
new_totals["groups_by_subtotal"].update({tax_group_name: updated_tax_group_vals})
4651
order.tax_totals = new_totals
4752

4853
def _get_name_sale_report(self, report_xml_id):
49-
""" Method similar to the '_get_name_invoice_report' of l10n_latam_invoice_document
54+
"""Method similar to the '_get_name_invoice_report' of l10n_latam_invoice_document
5055
Basically it allows different localizations to define it's own report
5156
This method should actually go in a sale_ux module that later can be extended by different localizations
5257
Another option would be to use report_substitute module and setup a subsitution with a domain
5358
"""
5459
self.ensure_one()
55-
if self.company_id.country_id.code == 'AR':
56-
return 'l10n_ar_sale.report_saleorder_document'
60+
if self.company_id.country_id.code == "AR":
61+
return "l10n_ar_sale.report_saleorder_document"
5762
return report_xml_id
5863

5964
def _create_invoices(self, grouped=False, final=False, date=None):
60-
""" Por alguna razon cuando voy a crear la factura a traves de una devolucion, no me esta permitiendo crearla
65+
"""Por alguna razon cuando voy a crear la factura a traves de una devolucion, no me esta permitiendo crearla
6166
y validarla porque resulta el campo tipo de documento esta quedando vacio. Este campo se llena y computa
6267
automaticamente al generar al modificar el diaro de una factura.
6368
6469
Si hacemos la prueba funcional desde la interfaz funciona, si intento importar la factura con el importador de
6570
Odoo funciona, pero si la voy a crear desde la devolucion inventario no se rellena dicho campo.
6671
6772
Para solventar decimos si tenemos facturas que usan documentos y que no tienen un tipo de documento, intentamos
68-
computarlo y asignarlo, esto aplica para cuando generamos una factura desde una orden de venta o suscripcion """
73+
computarlo y asignarlo, esto aplica para cuando generamos una factura desde una orden de venta o suscripcion"""
6974
invoices = super()._create_invoices(grouped=grouped, final=final, date=date)
7075

71-
# Intentamos Completar el dato tipo de documento si no seteado
76+
# Intentamos Completar el dato tipo de documento si no seteado
7277
to_fix = invoices.filtered(lambda x: x.l10n_latam_use_documents and not x.l10n_latam_document_type_id)
7378
to_fix._compute_l10n_latam_available_document_types()
7479
return invoices
7580

7681
def is_module_installed(self, module):
77-
module_installed = self.env['ir.module.module'].search([
78-
('name', '=', module),
79-
('state', '=', 'installed'),
80-
])
82+
module_installed = self.env["ir.module.module"].search(
83+
[
84+
("name", "=", module),
85+
("state", "=", "installed"),
86+
]
87+
)
8188
return True if module_installed else False

l10n_ar_sale/models/sale_order_line.py

+53-60
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,83 @@
22
# For copyright and license notices, see __manifest__.py file in module root
33
# directory
44
##############################################################################
5-
from odoo import models, fields, api, _
6-
from odoo.exceptions import UserError
75
import logging
6+
7+
from odoo import _, api, fields, models
8+
from odoo.exceptions import UserError
9+
810
_logger = logging.getLogger(__name__)
911

1012

1113
class SaleOrderLine(models.Model):
1214
_inherit = "sale.order.line"
1315

1416
report_price_unit = fields.Float(
15-
compute='_compute_report_prices_and_taxes',
16-
digits='Report Product Price',
17+
compute="_compute_report_prices_and_taxes",
18+
digits="Report Product Price",
1719
)
1820
price_unit_with_tax = fields.Float(
19-
compute='_compute_report_prices_and_taxes',
20-
digits='Product Price',
21-
)
22-
report_price_subtotal = fields.Monetary(
23-
compute='_compute_report_prices_and_taxes'
21+
compute="_compute_report_prices_and_taxes",
22+
digits="Product Price",
2423
)
24+
report_price_subtotal = fields.Monetary(compute="_compute_report_prices_and_taxes")
2525
report_price_net = fields.Float(
26-
compute='_compute_report_prices_and_taxes',
27-
digits='Report Product Price',
26+
compute="_compute_report_prices_and_taxes",
27+
digits="Report Product Price",
2828
)
2929
report_tax_id = fields.One2many(
3030
compute="_compute_report_prices_and_taxes",
31-
comodel_name='account.tax',
31+
comodel_name="account.tax",
3232
)
3333

3434
vat_tax_id = fields.Many2one(
35-
'account.tax',
36-
compute='_compute_vat_tax_id',
37-
)
38-
report_price_reduce = fields.Monetary(
39-
compute='_compute_report_price_reduce'
35+
"account.tax",
36+
compute="_compute_vat_tax_id",
4037
)
38+
report_price_reduce = fields.Monetary(compute="_compute_report_price_reduce")
4139

42-
@api.depends('price_unit', 'price_subtotal', 'order_id.vat_discriminated')
40+
@api.depends("price_unit", "price_subtotal", "order_id.vat_discriminated")
4341
def _compute_report_price_reduce(self):
4442
for line in self:
45-
price_type = line.price_subtotal \
46-
if line.order_id.vat_discriminated else line.price_total
47-
line.report_price_reduce = price_type / line.product_uom_qty \
48-
if line.product_uom_qty else 0.0
43+
price_type = line.price_subtotal if line.order_id.vat_discriminated else line.price_total
44+
line.report_price_reduce = price_type / line.product_uom_qty if line.product_uom_qty else 0.0
4945

5046
@api.depends(
51-
'tax_id.tax_group_id.l10n_ar_vat_afip_code',
47+
"tax_id.tax_group_id.l10n_ar_vat_afip_code",
5248
)
5349
def _compute_vat_tax_id(self):
5450
for rec in self:
5551
vat_tax_id = rec.tax_id.filtered(lambda x: x.tax_group_id.l10n_ar_vat_afip_code)
5652
if len(vat_tax_id) > 1:
57-
raise UserError(_('Only one vat tax allowed per line'))
53+
raise UserError(_("Only one vat tax allowed per line"))
5854
rec.vat_tax_id = vat_tax_id
5955

60-
@api.depends(
61-
'price_unit',
62-
'price_subtotal',
63-
'order_id.vat_discriminated'
64-
)
56+
@api.depends("price_unit", "price_subtotal", "order_id.vat_discriminated")
6557
def _compute_report_prices_and_taxes(self):
6658
for line in self:
6759
order = line.order_id
6860
taxes_included = not order.vat_discriminated
6961
price_unit = line.tax_id.with_context(round=False).compute_all(
70-
line.price_unit, order.currency_id, 1.0, line.product_id,
71-
order.partner_shipping_id)
62+
line.price_unit, order.currency_id, 1.0, line.product_id, order.partner_shipping_id
63+
)
7264
if not taxes_included:
73-
report_price_unit = price_unit['total_excluded']
65+
report_price_unit = price_unit["total_excluded"]
7466
report_price_subtotal = line.price_subtotal
7567
not_included_taxes = line.tax_id
76-
report_price_net = report_price_unit * (
77-
1 - (line.discount or 0.0) / 100.0)
68+
report_price_net = report_price_unit * (1 - (line.discount or 0.0) / 100.0)
7869
else:
7970
included_taxes = line.tax_id.filtered(lambda x: x.tax_group_id.l10n_ar_vat_afip_code)
80-
not_included_taxes = (
81-
line.tax_id - included_taxes)
82-
report_price_unit = included_taxes.with_context(
83-
round=False).compute_all(
84-
line.price_unit, order.currency_id, 1.0, line.product_id,
85-
order.partner_shipping_id)['total_included']
86-
report_price_net = report_price_unit * (
87-
1 - (line.discount or 0.0) / 100.0)
71+
not_included_taxes = line.tax_id - included_taxes
72+
report_price_unit = included_taxes.with_context(round=False).compute_all(
73+
line.price_unit, order.currency_id, 1.0, line.product_id, order.partner_shipping_id
74+
)["total_included"]
75+
report_price_net = report_price_unit * (1 - (line.discount or 0.0) / 100.0)
8876
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
8977
report_price_subtotal = included_taxes.compute_all(
90-
price, order.currency_id, line.product_uom_qty,
91-
line.product_id, order.partner_shipping_id)['total_included']
78+
price, order.currency_id, line.product_uom_qty, line.product_id, order.partner_shipping_id
79+
)["total_included"]
9280

93-
line.price_unit_with_tax = price_unit['total_included']
81+
line.price_unit_with_tax = price_unit["total_included"]
9482
line.report_price_subtotal = report_price_subtotal
9583
line.report_price_unit = report_price_unit
9684
line.report_price_net = report_price_net
@@ -109,32 +97,37 @@ def check_vat_tax(self):
10997
"""
11098
# por ahora, para no romper el install de sale_timesheet lo
11199
# desactivamos en la instalacion
112-
if self.env.context.get('install_mode'):
100+
if self.env.context.get("install_mode"):
113101
return True
114102
for rec in self.filtered(
115-
lambda x: not x.display_type and
116-
x.company_id.country_id == self.env.ref('base.ar') and
117-
x.company_id.l10n_ar_company_requires_vat):
118-
vat_taxes = rec.tax_id.filtered(
119-
lambda x: x.tax_group_id.l10n_ar_vat_afip_code)
103+
lambda x: not x.display_type
104+
and x.company_id.country_id == self.env.ref("base.ar")
105+
and x.company_id.l10n_ar_company_requires_vat
106+
):
107+
vat_taxes = rec.tax_id.filtered(lambda x: x.tax_group_id.l10n_ar_vat_afip_code)
120108
if len(vat_taxes) != 1:
121-
raise UserError(_(
122-
'Debe haber un único impuesto del grupo de impuestos "IVA" por línea, agréguelo a "%s". '
123-
'En caso de tenerlo, revise la configuración del impuesto, en opciones avanzadas, '
124-
'en el campo correspondiente "Grupo de Impuestos".',
125-
rec.product_id.name))
109+
raise UserError(
110+
_(
111+
'Debe haber un único impuesto del grupo de impuestos "IVA" por línea, agréguelo a "%s". '
112+
"En caso de tenerlo, revise la configuración del impuesto, en opciones avanzadas, "
113+
'en el campo correspondiente "Grupo de Impuestos".',
114+
rec.product_id.name,
115+
)
116+
)
126117

127118
def write(self, vals):
128119
res = super(SaleOrderLine, self).write(vals)
129120
# for performance we only check if tax or company is on vals
130-
if 'tax_id' in vals or 'company_id' in vals:
121+
if "tax_id" in vals or "company_id" in vals:
131122
self.check_vat_tax()
132123
return res
133124

134125
def _compute_tax_id(self):
135-
""" Agregado de taxes de modulo l10n_ar_tax segun fiscal position """
126+
"""Agregado de taxes de modulo l10n_ar_tax segun fiscal position"""
136127
super()._compute_tax_id()
137128

138-
for rec in self.filtered('order_id.fiscal_position_id.l10n_ar_tax_ids'):
129+
for rec in self.filtered("order_id.fiscal_position_id.l10n_ar_tax_ids"):
139130
date = rec.order_id.date_order
140-
rec.tax_id += rec.order_id.fiscal_position_id._l10n_ar_add_taxes(rec.order_partner_id, rec.company_id, date, 'perception')
131+
rec.tax_id += rec.order_id.fiscal_position_id._l10n_ar_add_taxes(
132+
rec.order_partner_id, rec.company_id, date, "perception"
133+
)
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from odoo import models, fields
1+
from odoo import fields, models
22

33

44
class ResConfigSettings(models.TransientModel):
5-
_inherit = 'res.config.settings'
5+
_inherit = "res.config.settings"
66

77
group_price_unit_with_tax = fields.Boolean(
88
"Unit Price w/ Taxes",
9-
implied_group='l10n_ar_sale.sale_price_unit_with_tax',
9+
implied_group="l10n_ar_sale.sale_price_unit_with_tax",
1010
)
1111
group_delivery_date = fields.Boolean(
1212
"Show Delivery Date in Quotations report and online budget",
13-
implied_group='l10n_ar_sale.group_delivery_date_on_report_online'
13+
implied_group="l10n_ar_sale.group_delivery_date_on_report_online",
1414
)

0 commit comments

Comments
 (0)