Skip to content

[18.0][MIG] pos_transfer_account: Migration to 18.0 - #8

Open
P-H-Phuc wants to merge 3 commits into
18.0from
18.0-mig-pos_transfer_account
Open

[18.0][MIG] pos_transfer_account: Migration to 18.0#8
P-H-Phuc wants to merge 3 commits into
18.0from
18.0-mig-pos_transfer_account

Conversation

@P-H-Phuc

@P-H-Phuc P-H-Phuc commented Nov 18, 2025

Copy link
Copy Markdown
Owner
  • This module was written to extend the functionality of odoo Point Of Sale about transfer account.
  • This module is usefull only in a multi Point of Sale context of multi company context.
  • With this module, it is now allowed to define for each PoS config a transfer account.
  • If this account is set, it will be used when user realizes "Cash In/Out" operation.
image
  • Remove pos_transfer_account/models/cash_box_in.py and pos_transfer_account/models/cash_box_out.py: its model was removed from 14.0.

@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 5cf6ad2 to 22a9c03 Compare November 19, 2025 08:45

@nguyenminhchien nguyenminhchien left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit tests

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file name should be CONFIG.md or CONFIGURE.md. Please double check.


If this account is set, it will be used when user realizes "Put Money In" or
"Take Money Out" operation, instead of the default one set in 'Invoicing' /
'Configuration' / 'Setting' Section. ("Inter-Banks Transfer Account" field) No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Suspense Account? on Journal
image

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@P-H-Phuc You missed this comment. Note that, there is no "Inter-Banks Transfer Account" in 'Invoicing' / 'Configuration' / 'Setting'

return super(
PosSession,
self.with_context(active_model="pos.session", active_ids=self.ids),
).try_cash_in_out(_type, amount, reason, extras)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how you test this module. You even did not import the file account_bank_statement_line.py to your models/__init__.py.
Anw, please remove account_bank_statement_line.py. Then, add this code block:

from odoo import models


class PosSession(models.Model):
    _inherit = "pos.session"

    def try_cash_in_out(self, _type, amount, reason, extras):
        if self.config_id.suspense_account_id:
            extras = extras or {}
            extras["counterpart_account_id"] = self.config_id.suspense_account_id.id
        return super().try_cash_in_out(_type, amount, reason, extras)

    def _prepare_account_bank_statement_line_vals(self, session, sign, amount, reason, extras):
        res = super()._prepare_account_bank_statement_line_vals(session, sign, amount, reason, extras)
        if extras.get("counterpart_account_id"):
            res["counterpart_account_id"] = extras["counterpart_account_id"]
        return res

class PosConfig(models.Model):
_inherit = "pos.config"

transfer_account_id = fields.Many2one(comodel_name="account.account")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
transfer_account_id = fields.Many2one(comodel_name="account.account")
suspense_account_id = fields.Many2one(comodel_name="account.account")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make it synchronize with the one created by Odoo SA.

class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

pos_transfer_account_id = fields.Many2one(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pos_transfer_account_id = fields.Many2one(
pos_suspense_account_id = fields.Many2one(

@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 22a9c03 to 511589f Compare November 21, 2025 08:40

@nguyenminhchien nguyenminhchien left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025-11-21 09:14:13,832 207521 INFO v18c_pos_transfer_account odoo.modules.loading: Loading module pos_transfer_account (56/56) 
2025-11-21 09:14:13,993 207521 INFO v18c_pos_transfer_account odoo.modules.registry: module pos_transfer_account: creating or updating database tables 
2025-11-21 09:14:14,113 207521 INFO v18c_pos_transfer_account odoo.modules.loading: loading pos_transfer_account/views/view_pos_config.xml 
2025-11-21 09:14:14,129 207521 INFO v18c_pos_transfer_account odoo.modules.loading: loading pos_transfer_account/views/res_config_settings_view.xml 
2025-11-21 09:14:14,162 207521 INFO v18c_pos_transfer_account odoo.modules.loading: Module pos_transfer_account: loading demo 
2025-11-21 09:14:14,162 207521 INFO v18c_pos_transfer_account odoo.modules.loading: loading pos_transfer_account/demo/account_account.xml 
2025-11-21 09:14:14,179 207521 INFO v18c_pos_transfer_account odoo.modules.loading: loading pos_transfer_account/demo/pos_config.xml 
2025-11-21 09:14:14,182 207521 WARNING v18c_pos_transfer_account odoo.modules.loading: Module pos_transfer_account demo data failed to install, installed without demo data 
Traceback (most recent call last):
  File "/home/chien/code/odoo/odoo/18.0/odoo/tools/convert.py", line 544, in _tag_root
    f(rec)
  File "/home/chien/code/odoo/odoo/18.0/odoo/tools/convert.py", line 444, in _tag_record
    record = model._load_records([data], self.mode == 'update')
  File "/home/chien/code/odoo/odoo/18.0/odoo/models.py", line 5502, in _load_records
    data['record']._load_records_write(data['values'])
  File "/home/chien/code/odoo/odoo/18.0/odoo/models.py", line 5420, in _load_records_write
    self.write(values)
  File "/home/chien/code/odoo/odoo/18.0/addons/point_of_sale/models/pos_config.py", line 543, in write
    result = super(PosConfig, self).write(vals)
  File "/home/chien/code/odoo/odoo/18.0/odoo/models.py", line 4741, in write
    raise ValueError("Invalid field %r on model %r" % (fname, self._name))
ValueError: Invalid field 'transfer_account_id' on model 'pos.config'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/chien/code/odoo/odoo/18.0/odoo/modules/loading.py", line 90, in load_demo
    load_data(env(su=True), idref, mode, kind='demo', package=package)
  File "/home/chien/code/odoo/odoo/18.0/odoo/modules/loading.py", line 72, in load_data
    tools.convert_file(env, package.name, filename, idref, mode, noupdate, kind)
  File "/home/chien/code/odoo/odoo/18.0/odoo/tools/convert.py", line 615, in convert_file
    convert_xml_import(env, module, fp, idref, mode, noupdate)
  File "/home/chien/code/odoo/odoo/18.0/odoo/tools/convert.py", line 686, in convert_xml_import
    obj.parse(doc.getroot())
  File "/home/chien/code/odoo/odoo/18.0/odoo/tools/convert.py", line 601, in parse
    self._tag_root(de)
  File "/home/chien/code/odoo/odoo/18.0/odoo/tools/convert.py", line 557, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing /home/chien/code/oca/pos/18.0/pos_transfer_account/demo/pos_config.xml:3, somewhere inside
<record id="pos_config_specific_transfer_account" model="pos.config">
        <field name="name">Point Of Sale with Specific Transfer Account</field>
        <field name="transfer_account_id" ref="account_pos_transfer_account"/>
        <field name="company_id" ref="base.main_company"/>
    </record>
2025-11-21 09:14:14,203 207521 INFO v18c_pos_transfer_account odoo.modules.loading: Module pos_transfer_account loaded in 0.37s, 209 queries (+209 other) 

@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 511589f to 0cd2a51 Compare November 24, 2025 04:18

@nguyenminhchien nguyenminhchien left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Update DESCRIPTION.md following a comment in my previous review

@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 0cd2a51 to 2612349 Compare November 24, 2025 07:58
@P-H-Phuc

Copy link
Copy Markdown
Owner Author

Resolved!

@P-H-Phuc

Copy link
Copy Markdown
Owner Author

Reference to OCA: https://github.com/OCA/pos/pull/1459

@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 2612349 to 75c957f Compare March 2, 2026 09:47
@P-H-Phuc

P-H-Phuc commented Mar 2, 2026

Copy link
Copy Markdown
Owner Author

@nguyenminhchien Could you please review this module? The update is based on the new request: https://tms.trobz.com/web#id=66226&action=543&model=tms.forge.ticket&view_type=form&cids=1&menu_id=424

@P-H-Phuc
P-H-Phuc requested a review from nguyenminhchien March 2, 2026 09:50
suspense_account = session.config_id.suspense_account_id
if not suspense_account:
suspense_account = session.company_id.transfer_account_id
res["counterpart_account_id"] = suspense_account.id

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, don't force the "counterpart_account_id" to be "suspense_account". Do update in the case of take money in / out only.
keep the logic as before

Image

just adjust the value of suspense account.

@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 75c957f to a90c85d Compare March 3, 2026 04:26
@P-H-Phuc
P-H-Phuc requested a review from nguyenminhchien March 3, 2026 11:05
@OCA-git-bot
OCA-git-bot force-pushed the 18.0-mig-pos_transfer_account branch from a90c85d to f1d9bf7 Compare April 9, 2026 18:17
@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch 4 times, most recently from c82a758 to 7f38b1b Compare May 5, 2026 07:55
@P-H-Phuc
P-H-Phuc force-pushed the 18.0-mig-pos_transfer_account branch from 7f38b1b to f09a908 Compare May 5, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants