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] l10n_it_declaration_of_intent: se elimino fattura già confermata non aggiorna plafond #4268

Merged
merged 2 commits into from
Jan 18, 2025
Merged
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 l10n_it_declaration_of_intent/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
],
"pre_init_hook": "pre_absorb_old_module",
"post_init_hook": "copy_m2m_values",
"demo": [
"demo/declaration_of_intent.xml",
],
}
59 changes: 59 additions & 0 deletions l10n_it_declaration_of_intent/demo/declaration_of_intent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" ?>
<odoo noupdate="1">
<record id="tax_08c" model="account.tax">
<field name="name">0% art.8c</field>
<field name="description">0a8c</field>
<field name="amount">0</field>
<field name="type_tax_use">sale</field>
<field
name="invoice_repartition_line_ids"
model="account.tax.repartition.line"
eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('l10n_it.2601', raise_if_not_found=False) or ref('l10n_generic_coa.tax_payable', raise_if_not_found=False) or obj().env['account.account'].search([('account_type', '=', 'liability_current')], limit=1).id,
}),
]"
/>
<field
name="refund_repartition_line_ids"
model="account.tax.repartition.line"
eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('l10n_it.2601', raise_if_not_found=False) or ref('l10n_generic_coa.tax_payable', raise_if_not_found=False) or obj().env['account.account'].search([('account_type', '=', 'liability_current')], limit=1).id,
}),
]"
/>
</record>
<record id="l10n_it_esportatore_abituale" model="account.fiscal.position">
<field name="name">Esportatore Abituale (Dichiarazione Intento)</field>
<field name="chart_template_id" ref="l10n_it.l10n_it_chart_template_generic" />
<field name="sequence">6</field>
<field name="auto_apply">1</field>
<field name="vat_required">1</field>
</record>
<record id="res_partner_1" model="res.partner">
<field name="name">Esportatore Abituale</field>
<field
eval="[Command.set([ref('base.res_partner_category_14'), ref('base.res_partner_category_12')])]"
name="category_id"
/>
<field name="is_company">1</field>
<field name="street">Vicolo Stretto, 1</field>
<field name="city">Monopoli</field>
<field name="zip">00000</field>
<field name="country_id" ref="base.it" />
<field name="fiscal_position_id" ref="l10n_it_esportatore_abituale" />
</record>
</odoo>
17 changes: 14 additions & 3 deletions l10n_it_declaration_of_intent/models/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,21 @@ def name_get(self):
)
return res

@api.depends("line_ids", "line_ids.amount", "limit_amount")
@api.depends(
"line_ids",
"line_ids.amount",
"limit_amount",
"line_ids.invoice_id",
"line_ids.invoice_id.state",
)
def _compute_amounts(self):
for record in self:
amount = sum(line.amount for line in record.line_ids)
amount = sum(
line.amount
for line in record.line_ids.filtered(
lambda li: li.invoice_id and li.invoice_id.state == "posted"
)
)
# ----- Force value to 0
if amount < 0.0:
amount = 0.0
Expand Down Expand Up @@ -277,7 +288,7 @@ class DeclarationOfIntentLine(models.Model):
)
amount = fields.Monetary()
base_amount = fields.Monetary(string="Base Amount")
invoice_id = fields.Many2one("account.move", string="Invoice")
invoice_id = fields.Many2one("account.move", string="Invoice", ondelete="cascade")
date_invoice = fields.Date(related="invoice_id.invoice_date", string="Date Invoice")
company_id = fields.Many2one(
"res.company", string="Company", related="declaration_id.company_id"
Expand Down
11 changes: 4 additions & 7 deletions l10n_it_declaration_of_intent/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z 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.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* 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 }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -456,9 +455,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">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>
Expand Down
20 changes: 20 additions & 0 deletions l10n_it_declaration_of_intent/tests/test_declaration_of_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,26 @@ def test_invoice_repost(self):
1,
)

def test_invoice_delete(self):
invoice = self._create_invoice(
"test_invoice_repost", self.partner1, tax=self.tax1
)
invoice_form = Form(invoice)
for tax in (self.tax2, self.tax22):
self._add_invoice_line_id(invoice_form, tax=tax)
invoice = invoice_form.save()
invoice.action_post()
invoice.button_draft()
invoice.with_context(force_delete=True).unlink()
self.assertEqual(
len(
self.declaration1.line_ids.filtered(
lambda line: line.invoice_id == invoice
)
),
0,
)

def test_multi_company(self):
"""Check that a user can only see and create declarations in his company."""
self.env = self.env(user=self.other_user)
Expand Down
Loading