Skip to content

Commit 68f932b

Browse files
[BKP] account_invoice_import: Backport to 13.0
1 parent 4472ecb commit 68f932b

9 files changed

+36
-37
lines changed

account_invoice_import/__manifest__.py

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

55
{
66
"name": "Account Invoice Import",
7-
"version": "14.0.3.3.2",
7+
"version": "13.0.1.0.1",
88
"category": "Accounting & Finance",
99
"license": "AGPL-3",
1010
"summary": "Import supplier invoices/refunds as PDF or XML files",

account_invoice_import/models/res_partner.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ def _compute_invoice_import_count(self):
3434

3535
def show_account_invoice_import_config(self):
3636
self.ensure_one()
37-
xmlid = "account_invoice_import.account_invoice_import_config_action"
38-
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
37+
action = self.env["ir.actions.act_window"].for_xml_id(
38+
"account_invoice_import", "account_invoice_import_config_action"
39+
)
3940
action["context"] = {
4041
"default_name": self.name,
4142
"default_partner_id": self.id,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
22
access_account_invoice_import_config_read,Read access on account.invoice.import.config to Invoicing and Payment,model_account_invoice_import_config,account.group_account_invoice,1,0,0,0
3-
access_account_invoice_import_config_readonly_grp,Read access on account.invoice.import.config to Account Readonly grp,model_account_invoice_import_config,account.group_account_readonly,1,0,0,0
43
access_account_invoice_import_config_full,Full access on account.invoice.import.config to Account Manager,model_account_invoice_import_config,account.group_account_manager,1,1,1,1
54
access_account_invoice_import,Access to account.invoice.import wizard,model_account_invoice_import,account.group_account_invoice,1,1,1,1

account_invoice_import/tests/test_invoice_import.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def test_import_in_invoice(self):
220220
.create_invoice(parsed_inv, import_c)
221221
)
222222
logger.debug("testing import with import config=%s", import_c)
223-
self.assertEqual(inv.move_type, parsed_inv["type"])
223+
self.assertEqual(inv.type, parsed_inv["type"])
224224
self.assertEqual(inv.company_id.id, self.company.id)
225225
self.assertFalse(
226226
inv.currency_id.compare_amounts(
@@ -282,7 +282,7 @@ def test_import_in_invoice_tax_include(self):
282282
.create_invoice(parsed_inv, import_c)
283283
)
284284
logger.debug("testing import with import config=%s", import_c)
285-
self.assertEqual(inv.move_type, parsed_inv["type"])
285+
self.assertEqual(inv.type, parsed_inv["type"])
286286
self.assertEqual(inv.company_id.id, self.company.id)
287287
self.assertFalse(
288288
inv.currency_id.compare_amounts(
@@ -441,7 +441,7 @@ def test_email_no_partner_match(self):
441441
move = self.env["account.move"].search(
442442
[
443443
("company_id", "=", self.company.id),
444-
("move_type", "=", "in_invoice"),
444+
("type", "=", "in_invoice"),
445445
("invoice_source_email", "like", sender_email),
446446
("state", "=", "draft"),
447447
]
@@ -458,7 +458,7 @@ def test_email_partner_no_invoice_config(self):
458458
move = self.env["account.move"].search(
459459
[
460460
("company_id", "=", self.company.id),
461-
("move_type", "=", "in_invoice"),
461+
("type", "=", "in_invoice"),
462462
("partner_id", "=", self.partner_with_email.id),
463463
("state", "=", "draft"),
464464
]
@@ -476,7 +476,7 @@ def test_email_partner_invoice_config(self):
476476
move = self.env["account.move"].search(
477477
[
478478
("company_id", "=", self.company.id),
479-
("move_type", "=", "in_invoice"),
479+
("type", "=", "in_invoice"),
480480
("partner_id", "=", partner.id),
481481
("state", "=", "draft"),
482482
]

account_invoice_import/views/account_invoice.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
name="%(account_invoice_import_action)d"
1616
string="Import Invoice File"
1717
context="{'wizard_default_state': 'update-from-invoice', 'default_invoice_id': id, 'default_partner_id': commercial_partner_id}"
18-
attrs="{'invisible': ['|', ('move_type', 'not in', ('in_invoice', 'in_refund')), ('state', '!=', 'draft')]}"
18+
attrs="{'invisible': ['|', ('type', 'not in', ('in_invoice', 'in_refund')), ('state', '!=', 'draft')]}"
1919
/>
2020
<!-- Button for quick access to the wizard
2121
to encode multiple invoices -->
@@ -24,7 +24,7 @@
2424
name="%(account_invoice_import_action)d"
2525
string="Import Next Invoice"
2626
context="{}"
27-
attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund'))]}"
27+
attrs="{'invisible': [('type', 'not in', ('in_invoice', 'in_refund'))]}"
2828
/>
2929
</button>
3030
</field>

account_invoice_import/views/account_journal_dashboard.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<field name="inherit_id" ref="account.account_journal_dashboard_kanban_view" />
1111
<field name="arch" type="xml">
1212
<button
13-
class="btn btn-primary o_button_upload_bill oe_kanban_action_button"
13+
class="btn btn-primary o_button_upload_bill"
1414
journal_type="purchase"
1515
position="attributes"
1616
>

account_invoice_import/views/res_partner.xml

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
<record id="view_partner_property_form" model="ir.ui.view">
99
<field name="model">res.partner</field>
1010
<field name="inherit_id" ref="account.view_partner_property_form" />
11-
<field
12-
name="groups_id"
13-
eval="[(4, ref('account.group_account_invoice')), (4, ref('account.group_account_readonly'))]"
14-
/>
11+
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]" />
1512
<field name="arch" type="xml">
1613
<button
1714
name="%(base.action_res_partner_bank_account_form)d"

account_invoice_import/wizard/account_invoice_import.py

+22-19
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ def _prepare_create_invoice_journal(self, parsed_inv, import_config, company, va
242242
else:
243243
journal_id = (
244244
self.env["account.move"]
245-
.with_context(
246-
default_move_type=parsed_inv["type"], company_id=company.id
247-
)
245+
.with_context(default_type=parsed_inv["type"], company_id=company.id)
248246
._get_default_journal()
249247
.id
250248
)
@@ -259,13 +257,13 @@ def _prepare_create_invoice_vals(self, parsed_inv, import_config):
259257
or self.env.company
260258
)
261259
vals = {
262-
"move_type": parsed_inv["type"],
260+
"type": parsed_inv["type"],
263261
"company_id": company.id,
264262
"invoice_origin": parsed_inv.get("origin"),
265263
"ref": parsed_inv.get("invoice_number"),
266264
"invoice_date": parsed_inv.get("date"),
267265
"narration": parsed_inv.get("narration"),
268-
"payment_reference": parsed_inv.get("payment_reference"),
266+
"invoice_payment_ref": parsed_inv.get("payment_reference"),
269267
"invoice_line_ids": [],
270268
}
271269
if parsed_inv["type"] in ("out_invoice", "out_refund"):
@@ -300,7 +298,7 @@ def _prepare_create_invoice_vals(self, parsed_inv, import_config):
300298
# set by invoice_date + invoice_payment_term_id otherwise
301299
vals["invoice_payment_term_id"] = False
302300
# Bank info
303-
if parsed_inv.get("iban") and vals["move_type"] == "in_invoice":
301+
if parsed_inv.get("iban") and vals["type"] == "in_invoice":
304302
partner_bank = self._match_partner_bank(
305303
partner,
306304
parsed_inv["iban"],
@@ -639,7 +637,7 @@ def invoice_already_exists(self, commercial_partner, parsed_inv):
639637
[
640638
("company_id", "=", company_id),
641639
("commercial_partner_id", "=", commercial_partner.id),
642-
("move_type", "=", parsed_inv["type"]),
640+
("type", "=", parsed_inv["type"]),
643641
("ref", "=ilike", parsed_inv.get("invoice_number")),
644642
],
645643
limit=1,
@@ -667,8 +665,9 @@ def goto_partner_not_found(self, parsed_inv, error_message):
667665
if country:
668666
vals["partner_country_id"] = country.id
669667
self.write(vals)
670-
xmlid = "account_invoice_import.account_invoice_import_action"
671-
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
668+
action = self.env["ir.actions.act_window"].for_xml_id(
669+
"account_invoice_import", "account_invoice_import_action"
670+
)
672671
action["res_id"] = self.id
673672
return action
674673

@@ -861,14 +860,15 @@ def import_invoice(self):
861860

862861
if not wiz_vals.get("import_config_id"):
863862
wiz_vals["state"] = "config"
864-
xmlid = "account_invoice_import.account_invoice_import_action"
865-
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
863+
action = self.env["ir.actions.act_window"].for_xml_id(
864+
"account_invoice_import", "account_invoice_import_action"
865+
)
866866
action["res_id"] = self.id
867867
else:
868868
draft_same_supplier_invs = amo.search(
869869
[
870870
("commercial_partner_id", "=", partner.id),
871-
("move_type", "=", parsed_inv["type"]),
871+
("type", "=", parsed_inv["type"]),
872872
("state", "=", "draft"),
873873
]
874874
)
@@ -877,8 +877,9 @@ def import_invoice(self):
877877
wiz_vals["state"] = "update"
878878
if len(draft_same_supplier_invs) == 1:
879879
wiz_vals["invoice_id"] = draft_same_supplier_invs[0].id
880-
xmlid = "account_invoice_import.account_invoice_import_action"
881-
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
880+
action = self.env["ir.actions.act_window"].for_xml_id(
881+
"account_invoice_import", "account_invoice_import_action"
882+
)
882883
action["res_id"] = self.id
883884
else:
884885
action = self.create_invoice_action(
@@ -905,8 +906,9 @@ def create_invoice_action(self, parsed_inv=None, import_config=None, origin=None
905906
assert self.import_config_id
906907
import_config = self.import_config_id.convert_to_import_config()
907908
invoice = self.create_invoice(parsed_inv, import_config, origin)
908-
xmlid = "account.action_move_in_invoice_type"
909-
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
909+
action = self.env["ir.actions.act_window"].for_xml_id(
910+
"account", "action_move_in_invoice_type"
911+
)
910912
action.update(
911913
{
912914
"view_mode": "form,tree,kanban",
@@ -1024,7 +1026,7 @@ def _prepare_global_adjustment_line(self, diff_amount, invoice, import_config):
10241026
accounts = import_config["product"].product_tmpl_id.get_product_accounts(
10251027
fiscal_pos=invoice.fiscal_position_id
10261028
)
1027-
if invoice.move_type in ("out_invoice", "out_refund"):
1029+
if invoice.type in ("out_invoice", "out_refund"):
10281030
account = accounts["income"]
10291031
else:
10301032
account = accounts["expense"]
@@ -1420,8 +1422,9 @@ def update_invoice(self):
14201422
)
14211423
% self.invoice_filename
14221424
)
1423-
xmlid = "account.action_move_in_invoice_type"
1424-
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
1425+
action = self.env["ir.actions.act_window"].for_xml_id(
1426+
"account", "action_move_in_invoice_type"
1427+
)
14251428
action.update(
14261429
{
14271430
"view_mode": "form,tree,kanban",

account_invoice_import/wizard/account_invoice_import_view.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@
5959
<field
6060
name="import_config_id"
6161
states="config,update-from-invoice,update"
62-
domain="[('partner_id', '=', partner_id)]"
6362
attrs="{'required': [('state', 'in', ('config', 'update-from-invoice', 'update'))]}"
6463
/>
6564
<field
6665
name="invoice_id"
6766
states="update,update-from-invoice"
68-
domain="[('state', '=', 'draft'), ('move_type', 'in', ('in_invoice', 'in_refund')), ('commercial_partner_id', '=', partner_id), ('move_type', '=', invoice_type)]"
67+
domain="[('state', '=', 'draft'), ('type', 'in', ('in_invoice', 'in_refund')), ('commercial_partner_id', '=', partner_id), ('type', '=', invoice_type)]"
6968
context="{'invoice_show_amount': True}"
7069
attrs="{'readonly': [('state', '=', 'update-from-invoice')]}"
7170
/>

0 commit comments

Comments
 (0)