Skip to content

Commit e8c3489

Browse files
committed
[FIX] _ar_stock_ux: fix remito
1 parent 324e1fa commit e8c3489

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

l10n_ar_stock_ux/models/stock_picking.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ class StockPicking(models.Model):
1717
"el mismo será asociado a los lotes sin número de despacho vinculados "
1818
"a la transferencia."
1919
)
20-
document_type_id = fields.Many2one(
21-
string="Document Type (AR)", compute="_compute_document_type_id", comodel_name="l10n_latam.document.type"
22-
)
2320
cot_numero_unico = fields.Char(
2421
"COT - Nro Único",
2522
help="Número único del último COT solicitado",
@@ -45,6 +42,15 @@ class StockPicking(models.Model):
4542
"* 0001-00000001\n"
4643
"* 0001-00000001,0001-00000002",
4744
)
45+
# agregamos estos dos campos calculados para facilitar mucho el código
46+
# el de fecha principalmente porque no hay nada facil para en qweb manipular y sacarlo en formato argentino
47+
document_type_id = fields.Many2one(
48+
string="Document Type (AR)", compute="_compute_cai_data", comodel_name="l10n_latam.document.type"
49+
)
50+
l10n_ar_cai_expiration_date = fields.Date(
51+
compute="_compute_cai_data",
52+
string="CAI Expiration Date",
53+
)
4854

4955
@api.onchange("l10n_ar_delivery_guide_number")
5056
def _format_document_number(self):
@@ -72,11 +78,15 @@ def _get_name_delivery_report(self, report_xml_id):
7278
return "l10n_ar_stock_ux.report_delivery_document"
7379
return report_xml_id
7480

75-
def _compute_document_type_id(self):
81+
@api.depends("l10n_ar_cai_data")
82+
def _compute_cai_data(self):
7683
for rec in self:
77-
if not self.l10n_ar_cai_data:
84+
if not rec.l10n_ar_cai_data:
7885
rec.document_type_id = False
86+
rec.l10n_ar_cai_expiration_date = False
7987
else:
88+
expiration_date = rec.l10n_ar_cai_data.get("cai_expiration_date")
89+
rec.l10n_ar_cai_expiration_date = fields.Date.to_date(expiration_date) if expiration_date else False
8090
rec.document_type_id = self.env["l10n_latam.document.type"].browse(
8191
rec.l10n_ar_cai_data.get("document_type_id")
8292
)
@@ -88,10 +98,9 @@ def _compute_l10n_ar_afip_barcode(self):
8898
rec.l10n_ar_delivery_guide_number
8999
and rec.document_type_id
90100
and rec.l10n_ar_cai_data
91-
and "cai_expiration_date" in rec.l10n_ar_cai_data
92-
and "cai_authorization_code" in rec.l10n_ar_cai_data
101+
and rec.l10n_ar_cai_expiration_date
93102
):
94-
cae_due = rec.l10n_ar_cai_data["cai_expiration_date"].strftime("%Y%m%d")
103+
cae_due = rec.l10n_ar_cai_expiration_date.strftime("%Y%m%d")
95104
pos_number = self.env["account.move"]._l10n_ar_get_document_number_parts(
96105
rec.l10n_ar_delivery_guide_number, rec.document_type_id.code
97106
)["point_of_sale"]
@@ -100,7 +109,7 @@ def _compute_l10n_ar_afip_barcode(self):
100109
str(rec.picking_type_id.report_partner_id.l10n_ar_vat or rec.company_id.partner_id.l10n_ar_vat),
101110
"%03d" % int(rec.document_type_id.code),
102111
"%05d" % pos_number,
103-
rec.l10n_ar_cai_data["cai_authorization_code"],
112+
rec.l10n_ar_cai_data.get("cai_authorization_code"),
104113
cae_due,
105114
]
106115
)

l10n_ar_stock_ux/views/report_deliveryslip.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,22 @@
8181
</table>
8282
</t>
8383
</div>
84+
8485
<div name="footer_right_column" class="col-4 text-right">
8586
<div t-if="not pre_printed_report and o.l10n_ar_cai_data">
86-
CAI: <span t-field="o.l10n_ar_cai_data.['l10n_ar_cai_authorization_code']"/>
87+
CAI: <span t-out="o.l10n_ar_cai_data['cai_authorization_code']"/>
8788
</div>
8889
<div t-if="not pre_printed_report and o.l10n_ar_cai_data">
89-
CAI Due Date: <span t-field="o.l10n_ar_cai_data.['l10n_ar_cai_expiration_date']"/>
90+
CAI Due Date: <span t-field="o.l10n_ar_cai_expiration_date"/>
9091
</div>
9192
<div name="pager" t-if="report_type == 'pdf'">
9293
Page: <span class="page"/>
9394
/ <span class="topage"/>
95+
</div>
9496
</div>
9597
</div>
96-
</div>
98+
</t>
9799
</t>
98-
</t>
99100

100101
<!-- remove default partner address -->
101102
<t t-set="address" position="attributes">

0 commit comments

Comments
 (0)