Skip to content

Commit

Permalink
[MIG] sale_third_party: Migration to 16
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Jan 14, 2025
1 parent 037dbe9 commit a8dd1f9
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 260 deletions.
1 change: 0 additions & 1 deletion sale_third_party/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import models
from . import wizard
7 changes: 1 addition & 6 deletions sale_third_party/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Sale third party invoice",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"author": "Eficent, CreuBlanca",
"website": "https://github.com/tegin/cb-addons",
"summary": "Creates inter company relations",
Expand All @@ -13,17 +13,12 @@
"depends": ["sale"],
"license": "AGPL-3",
"data": [
"security/ir.model.access.csv",
"security/security.xml",
"wizard/cash_third_party_sale_view.xml",
"reports/sale_third_party_report_templates.xml",
"reports/sale_third_party_report.xml",
"views/sale_order_views.xml",
"views/res_company_views.xml",
"views/partner_views.xml",
"views/account_payment_views.xml",
],
"installable": True,
"application": False,
"auto_install": False,
}
2 changes: 0 additions & 2 deletions sale_third_party/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ class AccountPayment(models.Model):
_inherit = "account.payment"

use_third_party_account = fields.Boolean(
"Use Third Party Account",
help="When you set this flag the payment will be recorded to "
"the third party account defined for this partner.",
)
third_party_account_id = fields.Many2one(
string="Third party account",
comodel_name="account.account",
readonly=True,
compute="_compute_third_party_account_id",
Expand Down
4 changes: 2 additions & 2 deletions sale_third_party/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class ResPartner(models.Model):
)
property_third_party_customer_account_id = fields.Many2one(
"account.account",
domain="[('deprecated', '=', False)," "('internal_type', '=', 'receivable')]",
domain="[('deprecated', '=', False), ('account_type', '=', 'asset_receivable')]",
company_dependent=True,
)
property_third_party_supplier_account_id = fields.Many2one(
"account.account",
domain="[('deprecated', '=', False)," "('internal_type', '=', 'payable')]",
domain="[('deprecated', '=', False), ('account_type', '=', 'liability_payable')]",
company_dependent=True,
)

Expand Down
2 changes: 1 addition & 1 deletion sale_third_party/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _prepare_third_party_order(self):
def _create_third_party_order(self):
vals = self._prepare_third_party_order()
order = self.env["sale.order"].create(vals)
order._compute_tax_id()
order._recompute_taxes()
return order

def _action_confirm(self):
Expand Down
2 changes: 0 additions & 2 deletions sale_third_party/security/ir.model.access.csv

This file was deleted.

8 changes: 4 additions & 4 deletions sale_third_party/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<field ref="model_account_move" name="model_id" />
<field
name="domain_force"
>[('move_type', 'in', ('entry')), ('third_party_sale_order', '=', True), '|', ('invoice_user_id', '=', user.id), ('invoice_user_id', '=', False)]</field>
>[('move_type', '=', 'entry'), ('third_party_sale_order', '=', True), '|', ('invoice_user_id', '=', user.id), ('invoice_user_id', '=', False)]</field>
<field name="groups" eval="[(4, ref('sales_team.group_sale_salesman'))]" />
</record>
<record id="account_move_see_all" model="ir.rule">
<field name="name">All Third Party Move</field>
<field ref="model_account_move" name="model_id" />
<field
name="domain_force"
>[('move_type', 'in', ('entry')), ('third_party_sale_order', '=', True)]</field>
>[('move_type', '=', 'entry'), ('third_party_sale_order', '=', True)]</field>
<field
name="groups"
eval="[(4, ref('sales_team.group_sale_salesman_all_leads'))]"
Expand All @@ -24,15 +24,15 @@
<field ref="model_account_move_line" name="model_id" />
<field
name="domain_force"
>[('move_id.type', 'in', ('entry')), ('move_id.third_party_sale_order', '=', True), '|', ('move_id.invoice_user_id', '=', user.id), ('move_id.invoice_user_id', '=', False)]</field>
>[('move_id.move_type', '=', 'entry'), ('move_id.third_party_sale_order', '=', True), '|', ('move_id.invoice_user_id', '=', user.id), ('move_id.invoice_user_id', '=', False)]</field>
<field name="groups" eval="[(4, ref('sales_team.group_sale_salesman'))]" />
</record>
<record id="account_move_line_see_all" model="ir.rule">
<field name="name">All Third Party Move Lines</field>
<field ref="model_account_move_line" name="model_id" />
<field
name="domain_force"
>[('move_id.type', 'in', ('entry')), ('move_id.third_party_sale_order', '=', True)]</field>
>[('move_id.move_type', '=', 'entry'), ('move_id.third_party_sale_order', '=', True)]</field>
<field
name="groups"
eval="[(4, ref('sales_team.group_sale_salesman_all_leads'))]"
Expand Down
115 changes: 31 additions & 84 deletions sale_third_party/tests/test_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def setUp(self):
"company_id": self.company.id,
"code": "Tra",
"name": "Transfer Account",
"user_type_id": self.browse_ref(
"account.data_account_type_current_assets"
).id,
"account_type": "asset_current",
"reconcile": False,
}
)
Expand All @@ -30,9 +28,7 @@ def setUp(self):
"company_id": self.company.id,
"code": "ThirdPartyCust",
"name": "Third party customer account",
"user_type_id": self.browse_ref(
"account.data_account_type_receivable"
).id,
"account_type": "asset_receivable",
"reconcile": True,
}
)
Expand All @@ -42,18 +38,40 @@ def setUp(self):
"company_id": self.company.id,
"code": "ThirdPartyCust2",
"name": "Third party customer account2",
"user_type_id": self.browse_ref(
"account.data_account_type_receivable"
).id,
"account_type": "asset_receivable",
"reconcile": True,
}
)
self.customer_acc_receivable = self.env["account.account"].create(
{
"company_id": self.company.id,
"code": "CustomerReceivable",
"name": "Third party customer account2",
"account_type": "asset_receivable",
"reconcile": True,
}
)
self.supplier_acc_payable = self.env["account.account"].create(
{
"company_id": self.company.id,
"code": "SupplierPayable",
"name": "Third party customer account2",
"account_type": "liability_payable",
"reconcile": True,
}
)
self.company.account_journal_payment_debit_account_id = (
self.customer_acc_receivable
)
self.company.account_journal_payment_credit_account_id = (
self.supplier_acc_payable
)
self.supplier_acc = self.env["account.account"].create(
{
"company_id": self.company.id,
"code": "ThirdPartySupp",
"name": "Third party supplier account",
"user_type_id": self.browse_ref("account.data_account_type_payable").id,
"account_type": "liability_payable",
"reconcile": True,
}
)
Expand Down Expand Up @@ -113,7 +131,7 @@ def test_multicompany(self):
"default_third_party_supplier_account_id": self.supplier_acc.id,
}
)
self.company.refresh()
self.company.invalidate_recordset()
self.assertEqual(
self.company.default_third_party_customer_account_id,
self.customer.property_third_party_customer_account_id,
Expand Down Expand Up @@ -277,7 +295,7 @@ def test_third_party_security(self):
"default_third_party_supplier_account_id": self.supplier_acc.id,
}
)
self.company.refresh()
self.company.invalidate_recordset()
sale_order = (
self.env["sale.order"]
.with_user(user)
Expand Down Expand Up @@ -327,41 +345,6 @@ def test_third_party_security(self):
self.assertEqual(sale_order.third_party_customer_in_state, "pending")
self.assertEqual(sale_order.third_party_customer_out_state, "pending")
self.assertEqual(sale_order.state, "done")
journal = self.env["account.journal"].search(
[("company_id", "=", self.company.id)], limit=1
)
statement = self.env["account.bank.statement"].create(
{"name": "Statement", "journal_id": journal.id}
)
wizard = (
self.env["cash.third.party.sale"]
.with_context(active_ids=statement.ids, active_model=statement._name)
.create({"sale_order_id": sale_order.id, "amount": 0})
)
wizard._onchange_sale_order()
self.assertEqual(wizard.amount, sale_order.amount_total)
wizard.amount = 100
wizard.run()
statement.balance_end_real = statement.balance_end
statement.button_post()
statement.button_validate_or_action()
self.assertEqual(sale_order.third_party_customer_in_residual, 10)
self.assertEqual(sale_order.third_party_customer_in_state, "pending")
statement = self.env["account.bank.statement"].create(
{"name": "Statement", "journal_id": journal.id}
)
wizard = (
self.env["cash.third.party.sale"]
.with_context(active_ids=statement.ids, active_model=statement._name)
.create({"sale_order_id": sale_order.id, "amount": 0})
)
wizard._onchange_sale_order()
self.assertEqual(wizard.amount, sale_order.third_party_customer_in_residual)
wizard.run()
statement.balance_end_real = statement.balance_end
statement.button_post()
statement.button_validate_or_action()
self.assertEqual(sale_order.third_party_customer_in_state, "paid")
# Test the outbound payment
bank_journal = self.env["account.journal"].create(
{
Expand Down Expand Up @@ -406,7 +389,7 @@ def test_third_party(self):
"default_third_party_supplier_account_id": self.supplier_acc.id,
}
)
self.company.refresh()
self.company.invalidate_recordset()
sale_order = self.env["sale.order"].create(
{
"company_id": self.company.id,
Expand Down Expand Up @@ -449,42 +432,6 @@ def test_third_party(self):
self.assertEqual(sale_order.third_party_customer_out_residual, 110)
self.assertEqual(sale_order.third_party_customer_in_state, "pending")
self.assertEqual(sale_order.third_party_customer_out_state, "pending")
self.assertEqual(sale_order.state, "done")
journal = self.env["account.journal"].search(
[("company_id", "=", self.company.id)], limit=1
)
statement = self.env["account.bank.statement"].create(
{"name": "Statement", "journal_id": journal.id}
)
wizard = (
self.env["cash.third.party.sale"]
.with_context(active_ids=statement.ids, active_model=statement._name)
.create({"sale_order_id": sale_order.id, "amount": 0})
)
wizard._onchange_sale_order()
self.assertEqual(wizard.amount, sale_order.amount_total)
wizard.amount = 100
wizard.run()
statement.balance_end_real = statement.balance_end
statement.button_post()
statement.button_validate_or_action()
self.assertEqual(sale_order.third_party_customer_in_residual, 10)
self.assertEqual(sale_order.third_party_customer_in_state, "pending")
statement = self.env["account.bank.statement"].create(
{"name": "Statement", "journal_id": journal.id}
)
wizard = (
self.env["cash.third.party.sale"]
.with_context(active_ids=statement.ids, active_model=statement._name)
.create({"sale_order_id": sale_order.id, "amount": 0})
)
wizard._onchange_sale_order()
self.assertEqual(wizard.amount, sale_order.third_party_customer_in_residual)
wizard.run()
statement.balance_end_real = statement.balance_end
statement.button_post()
statement.button_validate_or_action()
self.assertEqual(sale_order.third_party_customer_in_state, "paid")
# Test the outbound payment
bank_journal = self.env["account.journal"].create(
{
Expand Down
2 changes: 1 addition & 1 deletion sale_third_party/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_third_party.view_order_form" />
<field name="arch" type="xml">
<button name="preview_sale_order" position="before">
<button name="action_quotation_send" position="before">
<button
type="object"
name="third_party_invoice_print"
Expand Down
3 changes: 0 additions & 3 deletions sale_third_party/wizard/__init__.py

This file was deleted.

Binary file not shown.
Binary file not shown.
91 changes: 0 additions & 91 deletions sale_third_party/wizard/cash_third_party_sale.py

This file was deleted.

Loading

0 comments on commit a8dd1f9

Please sign in to comment.