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

[8.0] 349 Separar lineas por tipo de producto #463

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions l10n_es_aeat_mod349/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Contributors
* Ignacio Martínez (Top Consultant)
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Antonio Espinosa <antonioea@antiun.com>
* Daniel Rodriguez <drl.9319@gmail.com>

Maintainer
----------
Expand Down
1 change: 1 addition & 0 deletions l10n_es_aeat_mod349/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"version": "8.0.2.2.0",
"author": "Pexego, "
"Top Consultant, "
"Praxya, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Antiun Ingeniería S.L.,"
"Odoo Community Association (OCA)",
Expand Down
22 changes: 21 additions & 1 deletion l10n_es_aeat_mod349/i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_es_aeat_mod349
#
#
# Translators:
# Alejandro Santana <alejandrosantana@anubia.es>, 2015
msgid ""
Expand Down Expand Up @@ -696,6 +696,26 @@ msgstr "Tipo de soporte"
msgid "Support type:"
msgstr "Tipo de soporte:"

#. module: l10n_es_aeat_mod349
#: field:l10n.es.aeat.mod349.partner_record,total_consumable_storable_amount:0
msgid "Total operation Consumable and Storable products"
msgstr "Total operacion productos consumibles y almacenables"

#. module: l10n_es_aeat_mod349
#: field:l10n.es.aeat.mod349.partner_record,total_service_amount:0
msgid "Total operation service products"
msgstr "Total operacion productos servicio"

#. module: l10n_es_aeat_mod349
#: report:report_l10n_es_aeat_mod349.report:0
msgid "Consu. Sto. amount"
msgstr "Consu. Alma. total"

#. module: l10n_es_aeat_mod349
#: report:report_l10n_es_aeat_mod349.report:0
msgid "Service Amount"
msgstr "Servicio Total"

#. module: l10n_es_aeat_mod349
#: selection:account.invoice,operation_key:0
#: selection:l10n.es.aeat.mod349.partner_record,operation_key:0
Expand Down
38 changes: 33 additions & 5 deletions l10n_es_aeat_mod349/models/mod349.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,42 @@ def _create_349_partner_records(self, invoices):
self.ensure_one()
rec_obj = self.env['l10n.es.aeat.mod349.partner_record']
partner = invoices[0].commercial_partner_id
sum_credit = sum([invoice.cc_amount_untaxed for invoice in invoices
if invoice.type not in ('in_refund', 'out_refund')])
sum_debit = sum([invoice.cc_amount_untaxed for invoice in invoices
if invoice.type in ('in_refund', 'out_refund')])
sum_credit = 0
sum_debit = 0
sum_credit_service_amount = 0
sum_debit_service_amount = 0
sum_credit_consumable_amount = 0
sum_debit_consumable_amount = 0
for invoice in invoices:
if invoice.type not in ('in_refund', 'out_refund'):
sum_credit += invoice.cc_amount_untaxed
elif invoice.type in ('in_refund', 'out_refund'):
sum_debit += invoice.cc_amount_untaxed
for line in invoice.invoice_line:
if line.product_id.type == 'service':
if invoice.type not in ('in_refund', 'out_refund'):
sum_credit_service_amount += line.price_subtotal
elif invoice.type in ('in_refund', 'out_refund'):
sum_debit_service_amount += line.price_subtotal
elif line.product_id.type in ['consu', 'product']:
if invoice.type not in ('in_refund', 'out_refund'):
sum_credit_consumable_amount +=\
line.price_subtotal
elif invoice.type in ('in_refund', 'out_refund'):
sum_debit_consumable_amount +=\
line.price_subtotal
invoice_created = rec_obj.create(
{'report_id': self.id,
'partner_id': partner.id,
'partner_vat': _format_partner_vat(partner_vat=partner.vat,
country=partner.country_id),
'operation_key': invoices[0].operation_key,
'country_id': partner.country_id.id,
'total_operation_amount': sum_credit - sum_debit
'total_operation_amount': sum_credit - sum_debit,
'total_service_amount':
sum_credit_service_amount - sum_debit_service_amount,
'total_consumable_storable_amount':
sum_credit_consumable_amount - sum_debit_consumable_amount,
})
# Creation of partner detail lines
detail_obj = self.env['l10n.es.aeat.mod349.partner_record_detail']
Expand Down Expand Up @@ -290,6 +314,10 @@ def onchange_format_partner_vat(self, partner_vat, country_id):
operation_key = fields.Selection(
selection=OPERATION_KEYS, string='Operation key', required=True)
total_operation_amount = fields.Float(string='Total operation amount')
total_service_amount = fields.Float(
string='Total operation service products')
total_consumable_storable_amount = fields.Float(
string='Total operation Consumable and Storable products')
partner_record_ok = fields.Boolean(
compute="_check_partner_record_line", string='Partner Record OK',
help='Checked if partner record is OK')
Expand Down
16 changes: 10 additions & 6 deletions l10n_es_aeat_mod349/report/mod349_report.rml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<story>
[[repeatIn(objects,'report')]]
[[setLang(user.context_lang)]]
<blockTable colWidths="19cm" style="SeparatorTable">
<blockTable colWidths="20cm" style="SeparatorTable">
<tr><td><para style="Separator"></para></td></tr>
<tr><td><para style="SeparatorHeader">AEAT 349 MODEL</para></td></tr>
<tr><td><para style="Separator"></para></td></tr>
Expand All @@ -121,7 +121,7 @@
<!--
### REPORT INFO ###
-->
<blockTable colWidths="4cm,15cm" style="ReportInfo" id="ReportInfo">
<blockTable colWidths="4cm,16cm" style="ReportInfo" id="ReportInfo">
<tr>
<td><para style="ReportInfoDetail">Partner </para></td>
<td><para style="ReportInfo">[[report.company_id.name]]</para></td>
Expand All @@ -143,28 +143,32 @@
<!--
### PARTER RECORD LINES ###
-->
<blockTable colWidths="19cm" style="SeparatorTable">
<blockTable colWidths="20cm" style="SeparatorTable">
<tr><td><para style="Separator">PARTNER RECORD LINES</para></td></tr>
</blockTable>

<blockTable colWidths="8cm,2.5cm,3cm,3cm,2.5cm" style="DetailLineTable">
<blockTable colWidths="7cm,2cm,2cm,3cm,2cm,2cm,2cm" style="DetailLineTable">
<tr>
<td><para style="DetailLine">Partner</para></td>
<td><para style="DetailLine">Op.Key</para></td>
<td><para style="DetailLine">Country</para></td>
<td><para style="DetailLine">VAT</para></td>
<td><para style="DetailLine">Service Amount</para></td>
<td><para style="DetailLine">Consu. Sto. amount</para></td>
<td><para style="DetailLine">Op.Amount</para></td>
</tr>
</blockTable>

<section>
[[repeatIn(report.partner_record_ids, 'partner_record')]]
<blockTable colWidths="8cm,2.5cm,3cm,3cm,2.5cm" style="DataLineTable">
<blockTable colWidths="7cm,2cm,2cm,3cm,2cm,2cm,2cm" style="DataLineTable">
<tr>
<td><para style="DataLine">[[partner_record.partner_id.name or '-----']]</para></td>
<td><para style="DataLineCenter">[[partner_record.operation_key or '-']]</para></td>
<td><para style="DataLine">[[partner_record.country_id.name or '-----']]</para></td>
<td><para style="DataLine">[[partner_record.partner_vat or '-----']]</para></td>
<td><para style="DataLineRight">[[partner_record.total_service_amount and formatLang(partner_record.total_service_amount) or 0.0]] [[report.company_id.currency_id.code]]</para></td>
<td><para style="DataLineRight">[[partner_record.total_consumable_storable_amount and formatLang(partner_record.total_consumable_storable_amount) or 0.0]] [[report.company_id.currency_id.code]]</para></td>
<td><para style="DataLineRight">[[partner_record.total_operation_amount and formatLang(partner_record.total_operation_amount) or 0.0]] [[report.company_id.currency_id.code]]</para></td>
</tr>
</blockTable>
Expand Down Expand Up @@ -225,4 +229,4 @@
</blockTable>

</story>
</document>
</document>
4 changes: 4 additions & 0 deletions l10n_es_aeat_mod349/views/mod349_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<field name="country_id"/>
<field name="partner_vat"/>
<field name="partner_id"/>
<field name="total_service_amount"/>
<field name="total_consumable_storable_amount"/>
<field name="total_operation_amount"/>
</tree>
</field>
Expand All @@ -65,6 +67,8 @@
<field name="partner_id"/>
<field name="country_id"/>
<field name="partner_vat" on_change="onchange_format_partner_vat(partner_vat,country_id)"/>
<field name="total_service_amount"/>
<field name="total_consumable_storable_amount"/>
<field name="total_operation_amount"/>
</group>
</page>
Expand Down