mirror of
https://github.com/bringout/oca-financial.git
synced 2026-04-22 02:22:07 +02:00
Initial commit: OCA Financial packages (186 packages)
This commit is contained in:
commit
3e0e8473fb
8757 changed files with 947473 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import analytic_applicability
|
||||
from . import stock_move
|
||||
from . import stock_picking
|
||||
from . import stock_rule
|
||||
from . import stock_scrap
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2023 Quartile Limited
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAnalyticApplicability(models.Model):
|
||||
_inherit = "account.analytic.applicability"
|
||||
|
||||
business_domain = fields.Selection(
|
||||
selection_add=[("stock_move", "Stock Move")],
|
||||
ondelete={"stock_move": "cascade"},
|
||||
)
|
||||
stock_picking_type_id = fields.Many2one(
|
||||
"stock.picking.type",
|
||||
string="Operation Type",
|
||||
)
|
||||
|
||||
def _get_score(self, **kwargs):
|
||||
score = super()._get_score(**kwargs)
|
||||
if score >= 0 and self.stock_picking_type_id:
|
||||
if kwargs.get("picking_type") == self.stock_picking_type_id.id:
|
||||
score += 1
|
||||
else:
|
||||
return -1
|
||||
return score
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
# Copyright 2013 Julius Network Solutions
|
||||
# Copyright 2015 Clear Corp
|
||||
# Copyright 2016 OpenSynergy Indonesia
|
||||
# Copyright 2017 ForgeFlow S.L.
|
||||
# Copyright 2018 Hibou Corp.
|
||||
# Copyright 2023 Quartile Limited
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_name = "stock.move"
|
||||
_inherit = ["stock.move", "analytic.mixin"]
|
||||
|
||||
analytic_distribution = fields.Json(
|
||||
inverse="_inverse_analytic_distribution",
|
||||
)
|
||||
|
||||
def _inverse_analytic_distribution(self):
|
||||
"""If analytic distribution is set on move, write it on all move lines"""
|
||||
for move in self:
|
||||
move.move_line_ids.write(
|
||||
{"analytic_distribution": move.analytic_distribution}
|
||||
)
|
||||
|
||||
def _prepare_account_move_line(
|
||||
self, qty, cost, credit_account_id, debit_account_id, svl_id, description
|
||||
):
|
||||
self.ensure_one()
|
||||
res = super(StockMove, self)._prepare_account_move_line(
|
||||
qty, cost, credit_account_id, debit_account_id, svl_id, description
|
||||
)
|
||||
if not self.analytic_distribution:
|
||||
return res
|
||||
accounts = self.product_id.product_tmpl_id.get_product_accounts()
|
||||
account_valuation_id = (
|
||||
accounts.get("stock_valuation") and accounts["stock_valuation"].id
|
||||
)
|
||||
for line in res:
|
||||
if line[2]["account_id"] != account_valuation_id:
|
||||
# Add analytic account in debit line
|
||||
line[2].update({"analytic_distribution": self.analytic_distribution})
|
||||
return res
|
||||
|
||||
def _prepare_procurement_values(self):
|
||||
"""
|
||||
Allows to transmit analytic account from moves to new
|
||||
moves through procurement.
|
||||
"""
|
||||
res = super()._prepare_procurement_values()
|
||||
if self.analytic_distribution:
|
||||
res.update(
|
||||
{
|
||||
"analytic_distribution": self.analytic_distribution,
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
|
||||
"""
|
||||
We fill in the analytic account when creating the move line from
|
||||
the move
|
||||
"""
|
||||
res = super()._prepare_move_line_vals(
|
||||
quantity=quantity, reserved_quant=reserved_quant
|
||||
)
|
||||
if self.analytic_distribution:
|
||||
res.update({"analytic_distribution": self.analytic_distribution})
|
||||
return res
|
||||
|
||||
def _need_validate_distribution(self):
|
||||
"""Return moves are made outside the scope of the validation for now, since
|
||||
there could be cases where the necessity cannot be judged solely by the
|
||||
operation type.
|
||||
"""
|
||||
self.ensure_one()
|
||||
if self._is_in() and self._is_returned(valued_type="in"):
|
||||
return False
|
||||
elif self._is_out() and self._is_returned(valued_type="out"):
|
||||
return False
|
||||
elif self.company_id.anglo_saxon_accounting and self._is_dropshipped_returned():
|
||||
return False
|
||||
return True
|
||||
|
||||
def _action_done(self, cancel_backorder=False):
|
||||
for move in self:
|
||||
move.move_line_ids.analytic_distribution = move.analytic_distribution
|
||||
if not move._need_validate_distribution():
|
||||
continue
|
||||
move._validate_distribution(
|
||||
**{
|
||||
"product": move.product_id.id,
|
||||
"picking_type": move.picking_type_id.id,
|
||||
"business_domain": "stock_move",
|
||||
"company_id": move.company_id.id,
|
||||
}
|
||||
)
|
||||
return super()._action_done(cancel_backorder=cancel_backorder)
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
_name = "stock.move.line"
|
||||
_inherit = ["stock.move.line", "analytic.mixin"]
|
||||
|
||||
@api.model
|
||||
def _prepare_stock_move_vals(self):
|
||||
"""
|
||||
In the case move lines are created manually, we should fill in the
|
||||
new move created here with the analytic account if filled in.
|
||||
"""
|
||||
res = super()._prepare_stock_move_vals()
|
||||
if self.analytic_distribution:
|
||||
res.update({"analytic_distribution": self.analytic_distribution})
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
if "analytic_distribution" in vals:
|
||||
self.move_id.analytic_distribution = vals["analytic_distribution"]
|
||||
return super().write(vals)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# Copyright 2023 Quartile Limited
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = "stock.picking"
|
||||
|
||||
def button_validate(self):
|
||||
self = self.with_context(validate_analytic=True)
|
||||
return super().button_validate()
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Copyright 2024 Atte Isopuro <atte.isopuro@avoin.systems>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class StockRule(models.Model):
|
||||
_inherit = "stock.rule"
|
||||
|
||||
def _get_custom_move_fields(self):
|
||||
return super()._get_custom_move_fields() + ["analytic_distribution"]
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright (C) 2019 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import models
|
||||
|
||||
|
||||
class StockScrap(models.Model):
|
||||
_name = "stock.scrap"
|
||||
_inherit = ["stock.scrap", "analytic.mixin"]
|
||||
|
||||
def _prepare_move_values(self):
|
||||
res = super()._prepare_move_values()
|
||||
res.update(
|
||||
{
|
||||
"analytic_distribution": self.analytic_distribution,
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
def action_validate(self):
|
||||
self = self.with_context(validate_analytic=True)
|
||||
return super().action_validate()
|
||||
Loading…
Add table
Add a link
Reference in a new issue