Skip to content

Commit 31b4e19

Browse files
[BKP] account_invoice_import: Backport to 13.0
1 parent 4472ecb commit 31b4e19

7 files changed

+16
-22
lines changed
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

+6-8
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,7 +257,7 @@ 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"),
@@ -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,
@@ -868,7 +866,7 @@ def import_invoice(self):
868866
draft_same_supplier_invs = amo.search(
869867
[
870868
("commercial_partner_id", "=", partner.id),
871-
("move_type", "=", parsed_inv["type"]),
869+
("type", "=", parsed_inv["type"]),
872870
("state", "=", "draft"),
873871
]
874872
)
@@ -1024,7 +1022,7 @@ def _prepare_global_adjustment_line(self, diff_amount, invoice, import_config):
10241022
accounts = import_config["product"].product_tmpl_id.get_product_accounts(
10251023
fiscal_pos=invoice.fiscal_position_id
10261024
)
1027-
if invoice.move_type in ("out_invoice", "out_refund"):
1025+
if invoice.type in ("out_invoice", "out_refund"):
10281026
account = accounts["income"]
10291027
else:
10301028
account = accounts["expense"]

account_invoice_import/wizard/account_invoice_import_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<field
6666
name="invoice_id"
6767
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)]"
68+
domain="[('state', '=', 'draft'), ('type', 'in', ('in_invoice', 'in_refund')), ('commercial_partner_id', '=', partner_id), ('type', '=', invoice_type)]"
6969
context="{'invoice_show_amount': True}"
7070
attrs="{'readonly': [('state', '=', 'update-from-invoice')]}"
7171
/>

0 commit comments

Comments
 (0)