Skip to content

Commit

Permalink
temp rebasing PR 73 (41eb48e)
Browse files Browse the repository at this point in the history
  • Loading branch information
roboadhoc authored Feb 5, 2025
2 parents 3dfa544 + 41eb48e commit 35e6b4c
Show file tree
Hide file tree
Showing 30 changed files with 264 additions and 298 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

exclude: |
(?x)
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Library files can have extraneous formatting (even minimized)
Expand Down
49 changes: 24 additions & 25 deletions account_multi_store/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,33 @@
#
##############################################################################
{
'name': 'Multi Store for Accounting',
'version': "18.0.1.1.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'images': [
"name": "Multi Store for Accounting",
"version": "18.0.1.1.0",
"category": "Accounting",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"images": [],
"depends": [
"account",
"base_multi_store",
],
'depends': [
'account',
'base_multi_store',
"data": [
"views/account_journal_views.xml",
"views/account_move_line_views.xml",
"views/account_move_views.xml",
"views/account_payment_views.xml",
"views/res_store_views.xml",
"security/multi_store_security.xml",
],
'data': [
'views/account_journal_views.xml',
'views/account_move_line_views.xml',
'views/account_move_views.xml',
'views/account_payment_views.xml',
'views/res_store_views.xml',
'security/multi_store_security.xml',
],
'demo': [
"demo": [
# TODO fix demo data, perhups yml
# 'demo/account_demo.xml',
'demo/res_store_demo.xml',
"demo/res_store_demo.xml",
],
'installable': True,
'auto_install': True,
'application': False,
"installable": True,
"auto_install": True,
"application": False,
}
3 changes: 1 addition & 2 deletions account_multi_store/migrations/12.0.1.1.0/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(
env.cr, 'account_multi_store', 'migrations/12.0.1.1.0/mig_data.xml')
openupgrade.load_data(env.cr, "account_multi_store", "migrations/12.0.1.1.0/mig_data.xml")
12 changes: 6 additions & 6 deletions account_multi_store/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, api
from odoo import api, fields, models


class AccountJournal(models.Model):
_inherit = 'account.journal'
_inherit = "account.journal"

store_id = fields.Many2one(
'res.store',
'Store',
"res.store",
"Store",
help="Store used for data analysis and also users that are not of this"
" store, can only see this journal records but can not post or modify "
" any entry on them."
" any entry on them.",
)

@api.model
Expand All @@ -27,5 +27,5 @@ def _search(self, args, offset=0, limit=None, order=None):
user = self.env.user
# if superadmin, do not apply
if not self.env.is_superuser():
args += ['|', ('store_id', '=', False), ('store_id', 'child_of', user.store_ids.ids)]
args += ["|", ("store_id", "=", False), ("store_id", "child_of", user.store_ids.ids)]
return super()._search(args, offset, limit, order)
6 changes: 3 additions & 3 deletions account_multi_store/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields
from odoo import fields, models


class AccountMove(models.Model):
_inherit = 'account.move'
_inherit = "account.move"

store_id = fields.Many2one(
related='journal_id.store_id',
related="journal_id.store_id",
store=True,
)
34 changes: 18 additions & 16 deletions account_multi_store/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, _
from odoo import _, fields, models
from odoo.exceptions import UserError


class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
_inherit = "account.move.line"

store_id = fields.Many2one(
related='move_id.store_id',
related="move_id.store_id",
store=True,
)

Expand All @@ -20,26 +20,28 @@ def reconcile(self):
if store is None:
store = line.store_id
elif line.store_id.only_allow_reonciliaton_of_this_store and store != line.store_id:
raise UserError(_(
'For store "%s" you can only reconcile lines of same store') % (line.store_id.display_name))
raise UserError(
_('For store "%s" you can only reconcile lines of same store') % (line.store_id.display_name)
)
return super().reconcile()

def _prepare_exchange_difference_move_vals(self, amounts_list, company=None, exchange_date=None, **kwargs):
""" Ajustamos para usar diario de diferencia de cambio seteado en los stores
"""
vals = super()._prepare_exchange_difference_move_vals(amounts_list, company=company, exchange_date=exchange_date, **kwargs)
"""Ajustamos para usar diario de diferencia de cambio seteado en los stores"""
vals = super()._prepare_exchange_difference_move_vals(
amounts_list, company=company, exchange_date=exchange_date, **kwargs
)
company = self.company_id or company
if not company:
return
currency_exchange_journal = self.mapped('journal_id.store_id.currency_exchange_journal_id')
currency_exchange_journal = self.mapped("journal_id.store_id.currency_exchange_journal_id")
if len(currency_exchange_journal) > 1:
raise UserError(
'Esta intentando conciliar deuda de más de un Store con distintos diarios para ajuste por diferencia '
'de cambio\n* Stores: %s\n*Diarios: %s' % (
self.mapped('journal_id.store_id.name'),
currency_exchange_journal.mapped('name')))
"Esta intentando conciliar deuda de más de un Store con distintos diarios para ajuste por diferencia "
"de cambio\n* Stores: %s\n*Diarios: %s"
% (self.mapped("journal_id.store_id.name"), currency_exchange_journal.mapped("name"))
)
elif currency_exchange_journal:
vals['move_vals']['journal_id'] = currency_exchange_journal.id
vals["move_vals"]["journal_id"] = currency_exchange_journal.id

return vals

Expand All @@ -49,6 +51,6 @@ def action_register_payment(self, ctx=None):

def _apply_store_logic(self, action):
"""Lógica específica del store que puede ser reutilizada."""
if len(self.mapped('journal_id.store_id')) == 1:
action['context']['restrict_store_id'] = self.mapped('journal_id.store_id').id
if len(self.mapped("journal_id.store_id")) == 1:
action["context"]["restrict_store_id"] = self.mapped("journal_id.store_id").id
return action
6 changes: 3 additions & 3 deletions account_multi_store/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields
from odoo import fields, models


class AccountPayment(models.Model):
_inherit = 'account.payment'
_inherit = "account.payment"

store_id = fields.Many2one(
related='journal_id.store_id',
related="journal_id.store_id",
store=True,
)
10 changes: 6 additions & 4 deletions account_multi_store/models/account_payment_register.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from odoo import models, _
from odoo import models


class AccountPaymentRegister(models.TransientModel):
_inherit = "account.payment.register"

def _compute_available_journal_ids(self):
super()._compute_available_journal_ids()
restrict_store = self.env['res.store'].browse(self._context.get('restrict_store_id'))
restrict_store = self.env["res.store"].browse(self._context.get("restrict_store_id"))
if restrict_store:
for rec in self:
if restrict_store.only_allow_reonciliaton_of_this_store:
rec.available_journal_ids = rec.available_journal_ids.filtered(
lambda x: x.store_id == restrict_store)
lambda x: x.store_id == restrict_store
)
elif restrict_store:
rec.available_journal_ids = rec.available_journal_ids.filtered(
lambda x: not x.store_id.only_allow_reonciliaton_of_this_store)
lambda x: not x.store_id.only_allow_reonciliaton_of_this_store
)
23 changes: 12 additions & 11 deletions account_multi_store/models/res_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,36 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, api
from odoo import api, fields, models
from odoo.exceptions import UserError


class ResStore(models.Model):
_inherit = "res.store"

journal_ids = fields.One2many(
'account.journal',
'store_id',
'Journals',
"account.journal",
"store_id",
"Journals",
)

journals_count = fields.Integer(
compute='_compute_journals_count',
compute="_compute_journals_count",
)
currency_exchange_journal_id = fields.Many2one('account.journal')
currency_exchange_journal_id = fields.Many2one("account.journal")
only_allow_reonciliaton_of_this_store = fields.Boolean(
help='If enable, debt reconciliation will be only doable on items of this store')
help="If enable, debt reconciliation will be only doable on items of this store"
)

@api.depends('journal_ids')
@api.depends("journal_ids")
def _compute_journals_count(self):
for rec in self:
rec.journals_count = len(rec.journal_ids)

@api.constrains('currency_exchange_journal_id')
@api.constrains("currency_exchange_journal_id")
def _check_currency_exchange_journal_id(self):
for rec in self.filtered('currency_exchange_journal_id'):
for rec in self.filtered("currency_exchange_journal_id"):
if not rec.currency_exchange_journal_id.store_id:
rec.currency_exchange_journal_id.store_id = rec
elif rec.currency_exchange_journal_id.store_id.id != rec.id:
raise UserError('El diario de diferencia de cambio debe ser de esta misma sucursal')
raise UserError("El diario de diferencia de cambio debe ser de esta misma sucursal")
1 change: 0 additions & 1 deletion account_multi_store/security/multi_store_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@
<field name="domain_force">['|',('journal_id.store_id','=',False),('journal_id.store_id','child_of',[user.store_id.id])]</field>
</record>
</odoo>

38 changes: 16 additions & 22 deletions account_payment_pro_multi_store/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,21 @@
#
##############################################################################
{
'name': 'Payment Pro Multi Stores',
'version': "18.0.1.0.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'images': [
"name": "Payment Pro Multi Stores",
"version": "18.0.1.0.0",
"category": "Accounting",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"images": [],
"depends": ["account_multi_store", "account_payment_pro"],
"data": ["views/res_store_views.xml"],
"demo": [
"demo/res_store_demo.xml",
],
'depends': [
'account_multi_store',
'account_payment_pro'
],
'data': [
'views/res_store_views.xml'
],
'demo': [
'demo/res_store_demo.xml',
],
'installable': True,
'auto_install': False,
'application': False,
"installable": True,
"auto_install": False,
"application": False,
}
23 changes: 13 additions & 10 deletions account_payment_pro_multi_store/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
from odoo import models, api
from odoo import models


class AccountPayment(models.Model):
_inherit = 'account.payment'
_inherit = "account.payment"

def _get_to_pay_move_lines_domain(self):
""" Si soy pago de un payment group con store, y :
"""Si soy pago de un payment group con store, y :
* el store fuerza concilacion de mismo store, entonces buscamos deuda solo de ese store
* el store NO fuerza conciliacion de mismo store, buscamos deuda de cualquier store que no fuerce este comportamiento """
* el store NO fuerza conciliacion de mismo store, buscamos deuda de cualquier store que no fuerce este comportamiento"""
res = super()._get_to_pay_move_lines_domain()
if self.store_id.only_allow_reonciliaton_of_this_store:
res += [('store_id', '=', self.store_id.id)]
res += [("store_id", "=", self.store_id.id)]
if self.partner_id.commercial_partner_id.id:
self.with_context(restrict_store_id=self.store_id.id)._compute_available_journal_ids()
elif self.store_id:
res += ['|', ('store_id', '=', False), ('store_id.only_allow_reonciliaton_of_this_store', '=', False)]
res += ["|", ("store_id", "=", False), ("store_id.only_allow_reonciliaton_of_this_store", "=", False)]
return res

def compute_withholdings(self):
# only compute withholdings for payment groups where the store is not disabling it
return super(
AccountPayment, self.filtered(lambda x: not x.store_id.dont_compute_withholdings)).compute_withholdings()
AccountPayment, self.filtered(lambda x: not x.store_id.dont_compute_withholdings)
).compute_withholdings()

def _compute_available_journal_ids(self):
super()._compute_available_journal_ids()
restrict_store = self.env['res.store'].browse(self._context.get('restrict_store_id'))
restrict_store = self.env["res.store"].browse(self._context.get("restrict_store_id"))
if restrict_store:
for rec in self:
if restrict_store.only_allow_reonciliaton_of_this_store:
rec.available_journal_ids = rec.available_journal_ids.filtered(
lambda x: x.store_id == restrict_store)
lambda x: x.store_id == restrict_store
)
elif restrict_store:
rec.available_journal_ids = rec.available_journal_ids.filtered(
lambda x: not x.store_id.only_allow_reonciliaton_of_this_store)
lambda x: not x.store_id.only_allow_reonciliaton_of_this_store
)
Loading

0 comments on commit 35e6b4c

Please sign in to comment.