Skip to content

Commit

Permalink
odoo-upgrade-test | Add. Odoo Custom Modules
Browse files Browse the repository at this point in the history
* [Hari] | BAH-3299 | Add.  Sale Order Creation API with Custom Fields and Logic

* [Hari] | BAH-3299 | Update. unwanted files removed

* [Hari] | BAH-3329 | Add. Customer Master API Service with Custom Fields and Logic

* Revert "[Hari] | BAH-3329 | Add. Customer Master API Service with Custom Fields and Logic"

This reverts commit c2794e6.

* [Hari] | BAH-3329 | Add. Customer Master API Service with Custom Fields and Logic

* []

* Revert "[]"

This reverts commit 7051e9f.

* [Hari] | BAH-3298 | Add. Drug Master API Service with Customized Fields and Logic

* [Hari] | BAH-3300 | Drug Master API Service with Customized Fields and Logic

* [Hari] | BAH-3301 | Add.  Lab Test Creation API Service with Relevant Fields and Business Rules

* [Hari] | BAH-3302 | Lab Panel Creation API Service with Relevant Fields and Business Rules

* [Hari] | BAH-3302 | Update. logic updated

* [Hari] | BAH-3303 | Add. Saleable Service Creation API with Custom Fields and Logic

* [Hari] | BAH-3305 | Add. Bahmni_product: Custom Fields and Logic for Product Enhancement

* [Hari] | BAH-3308 | Add. Bahmni_purchase: Custom Fields and Logic for Purchase Enhancement

* [Hari] | BAH-3307 | Add. Bahmni_stock : Custom Fields and Logic for Product Enhancement

* [Hari] | BAH-3310 | Add. jss_data_import: Implemented Master Data Migration Logic

* [Hari] | Add. Custom Modules for Testing

* [Parvathy, Rahul] | Add. Custom Modules to image

* [Rahul] | Add. New Modules

* [Hari] | Updated. Customer endpoint method was updated.

* [Hari] | Update. All the updated code was moved to test branch

---------

Co-authored-by: Hari <[email protected]>
  • Loading branch information
rahu1ramesh and Hari authored Dec 8, 2023
1 parent 80300b4 commit 562c0ee
Show file tree
Hide file tree
Showing 108 changed files with 4,089 additions and 511 deletions.
1 change: 0 additions & 1 deletion bahmni_account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import models
4 changes: 0 additions & 4 deletions bahmni_account/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
{
'name': 'Bahmni Account',
'version': '1.0',
Expand All @@ -13,11 +12,8 @@
'images': [],
'depends': ['account'],
'data': [
'views/bahmni_account.xml',
'views/account_invoice_view.xml',
'views/account_config_settings.xml',
'views/company_view.xml',
'views/account_payment.xml',
],
'demo': [],
'qweb': [],
Expand Down
13 changes: 0 additions & 13 deletions bahmni_account/data/discount_accounts.xml

This file was deleted.

3 changes: 0 additions & 3 deletions bahmni_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
from . import rounding_off
from . import account_invoice
from . import account_invoice_line
from . import account_config_settings
from . import res_company
from . import account_payment
14 changes: 0 additions & 14 deletions bahmni_account/models/account_config_settings.py

This file was deleted.

189 changes: 35 additions & 154 deletions bahmni_account/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
from odoo.exceptions import UserError, ValidationError
import logging
Expand All @@ -14,27 +13,6 @@
class AccountInvoice(models.Model):
_inherit = 'account.move'

# # overridden this method to deduct discounted amount from total of invoice
@api.depends('invoice_line_ids.price_subtotal','line_ids.tax_line_id.amount',
'currency_id', 'company_id', 'date', 'move_type', 'discount')
def _compute_amount(self):
round_curr = self.currency_id.round
self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids)
self.amount_tax = sum(line.price_total for line in self.invoice_line_ids) - sum(line.price_subtotal for line in self.invoice_line_ids)
amount_total = self.amount_untaxed + self.amount_tax - self.discount
self.round_off_amount = self.env['rounding.off'].round_off_value_to_nearest(amount_total)
self.amount_total = self.amount_untaxed + self.amount_tax - self.discount + self.round_off_amount
amount_total_company_signed = self.amount_total
amount_untaxed_signed = self.amount_untaxed
if self.currency_id and self.company_id and self.currency_id != self.company_id.currency_id:
currency_id = self.currency_id.with_context(date=self.date_invoice)
amount_total_company_signed = currency_id.compute(self.amount_total, self.company_id.currency_id)
amount_untaxed_signed = currency_id.compute(self.amount_untaxed, self.company_id.currency_id)
sign = self.move_type in ['in_refund', 'out_refund'] and -1 or 1
self.amount_total_in_currency_signed = amount_total_company_signed * sign
self.amount_total_signed = self.amount_total * sign
self.amount_untaxed_signed = amount_untaxed_signed * sign

discount_type = fields.Selection([('none', 'No Discount'),
('fixed', 'Fixed'),
('percentage', 'Percentage')],
Expand All @@ -45,7 +23,7 @@ def _compute_amount(self):
disc_acc_id = fields.Many2one('account.account',
string="Discount Account Head")
round_off_amount = fields.Monetary(string="Round Off Amount",
compute=_compute_amount)
)

@api.onchange('invoice_line_ids')
def onchange_invoice_lines(self):
Expand Down Expand Up @@ -93,139 +71,42 @@ def _find_batch(self, product, qty, location, picking):
message = ("<b>Auto validation Failed</b> <br/> <b>Reason:</b> There are no Batches/Serial no's available for <a href=# data-oe-model=product.product data-oe-id=%d>%s</a> product") % (product.id,product.name)
picking.message_post(body=message)
return False

def button_dummy(self):
return self._compute_amount()


def action_move_create(self):
#This method is overriden to pass the Discount Journal Entry.
""" Creates invoice related analytics and financial move lines """
account_move = self.env['account.move']

for inv in self:
if not inv.journal_id.sequence_id:
raise UserError(_('Please define sequence on the journal related to this invoice.'))
if not inv.invoice_line_ids:
raise UserError(_('Please create some invoice lines.'))
if inv.move_id:
continue

ctx = dict(self._context, lang=inv.partner_id.lang)

if not inv.date_invoice:
inv.with_context(ctx).write({'date_invoice': fields.Date.context_today(self)})
company_currency = inv.company_id.currency_id

# create move lines (one per invoice line + eventual taxes and analytic lines)
iml = inv.invoice_line_move_line_get()
iml += inv.tax_line_move_line_get()

diff_currency = inv.currency_id != company_currency
# create one move line for the total and possibly adjust the other lines amount
total, total_currency, iml = inv.with_context(ctx).compute_invoice_totals(company_currency, iml)

name = inv.name or '/'
if inv.payment_term_id:
totlines = inv.with_context(ctx).payment_term_id.with_context(currency_id=company_currency.id).compute(total, inv.date_invoice)[0]
res_amount_currency = total_currency
ctx['date'] = inv._get_currency_rate_date()
for i, t in enumerate(totlines):
if inv.currency_id != company_currency:
amount_currency = company_currency.with_context(ctx).compute(t[1], inv.currency_id)
else:
amount_currency = False

# last line: add the diff
res_amount_currency -= amount_currency or 0
if i + 1 == len(totlines):
amount_currency += res_amount_currency

iml.append({
'type': 'dest',
'name': name,
'price': t[1],
'account_id': inv.account_id.id,
'date_maturity': t[0],
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
else:
iml.append({
'type': 'dest',
'name': name,
'price': total,
'account_id': inv.account_id.id,
'date_maturity': inv.date_due,
'amount_currency': diff_currency and total_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
part = self.env['res.partner']._find_accounting_partner(inv.partner_id)
line = [(0, 0, self.line_get_convert(l, part.id)) for l in iml]
line = inv.group_lines(iml, line)

journal = inv.journal_id.with_context(ctx)
line = inv.finalize_invoice_move_lines(line)
date = inv.date or inv.date_invoice
move_vals = {
'ref': inv.reference,
'line_ids': line,
'journal_id': journal.id,
'date': date,
'narration': inv.comment,
}
ctx['company_id'] = inv.company_id.id
ctx['invoice'] = inv
ctx_nolang = ctx.copy()
ctx_nolang.pop('lang', None)
move = account_move.with_context(ctx_nolang).create(move_vals)
#=============Customized code starts=========
if inv.discount:
if inv.type == 'out_refund':
move_line = move.line_ids.filtered(lambda l:l.name==inv.name)
move_line.credit -= inv.discount
move_line_vals = {
'name':'Discount',
'company_id':move.company_id.id,
'account_id':inv.disc_acc_id.id,
'credit':inv.discount,
'date_maturity':date,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id,
'partner_id':move_line.partner_id.id,
'move_id':move.id,
}
self.env['account.move.line'].create(move_line_vals)

else:
move_line = move.line_ids.filtered(lambda l:l.name=='/')
move_line.debit -= inv.discount
move_line_vals = {
'name':'Discount',
'company_id':move.company_id.id,
'account_id':inv.disc_acc_id.id,
'debit':inv.discount,
'date_maturity':date,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id,
'partner_id':move_line.partner_id.id,
'move_id':move.id,
}
self.env['account.move.line'].create(move_line_vals)
#===========Customized code ends=============
# Pass invoice in context in method post: used if you want to get the same
# account move reference when creating the same invoice after a cancelled one:
move.post()
# make the invoice point to that move
vals = {
'move_id': move.id,
'date': date,
'move_name': move.name,
}
inv.with_context(ctx).write(vals)
def button_dummy(self):
return True




def action_post(self):

for inv in self:
print("inv",inv.discount,inv.round_off_amount,inv.amount_total)

find_val = (inv.amount_total - inv.discount ) + inv.round_off_amount

print("find_val",find_val)
differnece_vals = inv.amount_total - find_val
print("differnece_vals",differnece_vals)


for move_line in inv.line_ids:
update = False
print("move_line",move_line.display_type)
if move_line.display_type =='payment_term':
move_line.debit = move_line.debit - differnece_vals



moves_with_payments = self.filtered('payment_id')
other_moves = self - moves_with_payments
if moves_with_payments:
moves_with_payments.payment_id.action_post()
if other_moves:
other_moves._post(soft=False)
return False



@api.model
def _prepare_refund(self, invoice, date_invoice=None, date=None, description=None, journal_id=None):
Expand Down
1 change: 0 additions & 1 deletion bahmni_account/models/account_invoice_line.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, api, fields


Expand Down
46 changes: 0 additions & 46 deletions bahmni_account/models/account_payment.py

This file was deleted.

1 change: 0 additions & 1 deletion bahmni_account/models/res_company.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields


Expand Down
8 changes: 0 additions & 8 deletions bahmni_account/models/res_partner.py

This file was deleted.

1 change: 0 additions & 1 deletion bahmni_account/models/rounding_off.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api

class RoundingOff(models.Model):
Expand Down
4 changes: 4 additions & 0 deletions bahmni_account/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_count_report_account_user,Account Count Report Account User,model_account_count_report,account.group_account_user,1,1,1,0
access_rounding_off,access_rounding_off,model_rounding_off,,1,1,1,1
access_account_report,access_account_report,model_account_report,,1,1,1,1
18 changes: 0 additions & 18 deletions bahmni_account/views/account_config_settings.xml

This file was deleted.

Loading

0 comments on commit 562c0ee

Please sign in to comment.