summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-08-26 11:13:23 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-08-26 11:13:23 +0700
commitb557dfe5249e471a1b7277d5c189313ce303347b (patch)
tree70e29854ae31c16910f49afc7b15b25a1bd7d9b7
parenta28e01d3df18301057c33930b11655cc9d623b64 (diff)
temporary solution for internal use tax
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py2
-rw-r--r--indoteknik_custom/models/stock_move.py155
-rw-r--r--indoteknik_custom/models/stock_picking.py7
-rw-r--r--indoteknik_custom/views/stock_picking_type.xml18
5 files changed, 183 insertions, 0 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 26e0ddb7..c390a7a2 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -32,6 +32,7 @@
'views/crm_lead.xml',
'views/sale_order.xml',
'views/account_asset_views.xml',
+ 'views/stock_picking_type.xml',
'report/report.xml',
'report/report_banner_banner.xml',
'report/report_banner_banner2.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 25341923..a81306b6 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -19,3 +19,5 @@ from . import sale_monitoring_detail
from . import sale_monitoring
from . import account_move
from . import account_asset
+from . import stock_move
+from . import stock_picking \ No newline at end of file
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
new file mode 100644
index 00000000..3804198a
--- /dev/null
+++ b/indoteknik_custom/models/stock_move.py
@@ -0,0 +1,155 @@
+from odoo import fields, models, api
+from odoo.exceptions import UserError
+
+
+class StockMove(models.Model):
+ _inherit = 'stock.move'
+
+ def _account_entry_move(self, qty, description, svl_id, cost):
+ """ Accounting Valuation Entries """
+ self.ensure_one()
+ if self.product_id.type != 'product':
+ # no stock valuation for consumable products
+ return False
+ if self.restrict_partner_id:
+ # if the move isn't owned by the company, we don't make any valuation
+ return False
+
+ company_from = self._is_out() and self.mapped('move_line_ids.location_id.company_id') or False
+ company_to = self._is_in() and self.mapped('move_line_ids.location_dest_id.company_id') or False
+
+ journal_id, acc_src, acc_dest, acc_valuation = self._get_accounting_data_for_valuation()
+ # Create Journal Entry for products arriving in the company; in case of routes making the link between several
+ # warehouse of the same company, the transit location belongs to this company, so we don't need to create accounting entries
+ if self._is_in():
+ if self._is_returned(valued_type='in'):
+ self.with_company(company_to)._create_account_move_line(acc_dest, acc_valuation, journal_id, qty,
+ description, svl_id, cost)
+ else:
+ self.with_company(company_to)._create_account_move_line(acc_src, acc_valuation, journal_id, qty,
+ description, svl_id, cost)
+
+ # Create Journal Entry for products leaving the company
+ if self._is_out():
+ cost = -1 * cost
+ if self._is_returned(valued_type='out'):
+ self.with_company(company_from)._create_account_move_line(acc_valuation, acc_src, journal_id, qty,
+ description, svl_id, cost)
+ else: # custom here for ppn internal use, acc_dest = 538, acc_valuation = 400, charge from virtual location and persediaan
+ self.with_company(company_from)._create_account_move_line(acc_valuation, acc_dest, journal_id, qty,
+ description, svl_id, cost)
+ self.with_company(company_from)._create_account_move_line(440,538,journal_id,qty,description,svl_id,cost * (11 / 100))
+
+ if self.company_id.anglo_saxon_accounting:
+ # Creates an account entry from stock_input to stock_output on a dropship move. https://github.com/odoo/odoo/issues/12687
+ if self._is_dropshipped():
+ if cost > 0:
+ self.with_company(self.company_id)._create_account_move_line(acc_src, acc_valuation, journal_id,
+ qty, description, svl_id, cost)
+ else:
+ cost = -1 * cost
+ self.with_company(self.company_id)._create_account_move_line(acc_valuation, acc_dest, journal_id,
+ qty, description, svl_id, cost)
+ elif self._is_dropshipped_returned():
+ if cost > 0:
+ self.with_company(self.company_id)._create_account_move_line(acc_valuation, acc_src, journal_id,
+ qty, description, svl_id, cost)
+ else:
+ cost = -1 * cost
+ self.with_company(self.company_id)._create_account_move_line(acc_dest, acc_valuation, journal_id,
+ qty, description, svl_id, cost)
+
+ if self.company_id.anglo_saxon_accounting:
+ # Eventually reconcile together the invoice and valuation accounting entries on the stock interim accounts
+ self._get_related_invoices()._stock_account_anglo_saxon_reconcile_valuation(product=self.product_id)
+
+ # def _create_account_move_line(self, credit_account_id, debit_account_id, journal_id, qty, description, svl_id,
+ # cost):
+ # self.ensure_one()
+ # AccountMove = self.env['account.move'].with_context(default_journal_id=journal_id)
+ #
+ # move_lines = self._prepare_account_move_line(qty, cost, credit_account_id, debit_account_id, description)
+ # if move_lines:
+ # date = self._context.get('force_period_date', fields.Date.context_today(self))
+ # new_account_move = AccountMove.sudo().create({
+ # 'journal_id': journal_id,
+ # 'line_ids': move_lines,
+ # 'date': date,
+ # 'ref': description,
+ # 'stock_move_id': self.id,
+ # 'stock_valuation_layer_ids': [(6, None, [svl_id])],
+ # 'move_type': 'entry',
+ # })
+ # new_account_move._post()
+ #
+ # def _prepare_account_move_line(self, qty, cost, credit_account_id, debit_account_id, description):
+ # """
+ # Generate the account.move.line values to post to track the stock valuation difference due to the
+ # processing of the given quant.
+ # """
+ # self.ensure_one()
+ #
+ # # the standard_price of the product may be in another decimal precision, or not compatible with the coinage of
+ # # the company currency... so we need to use round() before creating the accounting entries.
+ # debit_value = self.company_id.currency_id.round(cost)
+ # credit_value = debit_value
+ #
+ # valuation_partner_id = self._get_partner_id_for_valuation_lines()
+ # res = [(0, 0, line_vals) for line_vals in
+ # self._generate_valuation_lines_data(valuation_partner_id, qty, debit_value, credit_value,
+ # debit_account_id, credit_account_id, description).values()]
+ #
+ # return res
+ #
+ # def _generate_valuation_lines_data(self, partner_id, qty, debit_value, credit_value, debit_account_id,
+ # credit_account_id, description):
+ # # This method returns a dictionary to provide an easy extension hook to modify the valuation lines (see purchase for an example)
+ # self.ensure_one()
+ # debit_line_vals = {
+ # 'name': description,
+ # 'product_id': self.product_id.id,
+ # 'quantity': qty,
+ # 'product_uom_id': self.product_id.uom_id.id,
+ # 'ref': description,
+ # 'partner_id': partner_id,
+ # 'debit': debit_value if debit_value > 0 else 0,
+ # 'credit': -debit_value if debit_value < 0 else 0,
+ # 'account_id': debit_account_id,
+ # }
+ #
+ # credit_line_vals = {
+ # 'name': description,
+ # 'product_id': self.product_id.id,
+ # 'quantity': qty,
+ # 'product_uom_id': self.product_id.uom_id.id,
+ # 'ref': description,
+ # 'partner_id': partner_id,
+ # 'credit': credit_value if credit_value > 0 else 0,
+ # 'debit': -credit_value if credit_value < 0 else 0,
+ # 'account_id': credit_account_id,
+ # }
+ #
+ # rslt = {'credit_line_vals': credit_line_vals, 'debit_line_vals': debit_line_vals}
+ # if credit_value != debit_value:
+ # # for supplier returns of product in average costing method, in anglo saxon mode
+ # diff_amount = debit_value - credit_value
+ # price_diff_account = self.product_id.property_account_creditor_price_difference
+ #
+ # if not price_diff_account:
+ # price_diff_account = self.product_id.categ_id.property_account_creditor_price_difference_categ
+ # if not price_diff_account:
+ # raise UserError(
+ # _('Configuration error. Please configure the price difference account on the product or its category to process this operation.'))
+ #
+ # rslt['price_diff_line_vals'] = {
+ # 'name': self.name,
+ # 'product_id': self.product_id.id,
+ # 'quantity': qty,
+ # 'product_uom_id': self.product_id.uom_id.id,
+ # 'ref': description,
+ # 'partner_id': partner_id,
+ # 'credit': diff_amount > 0 and diff_amount or 0,
+ # 'debit': diff_amount < 0 and -diff_amount or 0,
+ # 'account_id': price_diff_account.id,
+ # }
+ # return rslt
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
new file mode 100644
index 00000000..1dfef114
--- /dev/null
+++ b/indoteknik_custom/models/stock_picking.py
@@ -0,0 +1,7 @@
+from odoo import fields, models, api
+
+
+class StockPicking(models.Model):
+ _inherit = 'stock.picking.type'
+
+ is_internal_use = fields.Boolean(string="Internal Use")
diff --git a/indoteknik_custom/views/stock_picking_type.xml b/indoteknik_custom/views/stock_picking_type.xml
new file mode 100644
index 00000000..7a8f45dd
--- /dev/null
+++ b/indoteknik_custom/views/stock_picking_type.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="stock_picking_type_form_view_inherit" model="ir.ui.view">
+ <field name="name">Stock Picking Type</field>
+ <field name="model">stock.picking.type</field>
+ <field name="inherit_id" ref="stock.view_picking_type_form"/>
+ <field name="arch" type="xml">
+ <field name="warehouse_id" position="after">
+ <field name="is_internal_use"
+ string="Internal Use"
+ type="object"
+ />
+ </field>
+ </field>
+ </record>
+ </data>
+</odoo> \ No newline at end of file