diff --git a/bahmni_account/__init__.py b/bahmni_account/__init__.py
index 50bdf71..0650744 100644
--- a/bahmni_account/__init__.py
+++ b/bahmni_account/__init__.py
@@ -1,3 +1 @@
-# -*- coding: utf-8 -*-
from . import models
-# ~ from . import report
diff --git a/bahmni_account/__manifest__.py b/bahmni_account/__manifest__.py
index 69adf75..71e768d 100644
--- a/bahmni_account/__manifest__.py
+++ b/bahmni_account/__manifest__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
{
'name': 'Bahmni Account',
'version': '1.0',
@@ -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': [],
diff --git a/bahmni_account/data/discount_accounts.xml b/bahmni_account/data/discount_accounts.xml
deleted file mode 100644
index eb196ab..0000000
--- a/bahmni_account/data/discount_accounts.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- Discount
-
-
-
-
- Overcharge
-
-
-
\ No newline at end of file
diff --git a/bahmni_account/doc/ChangeLog.txt b/bahmni_account/doc/ChangeLog.txt
deleted file mode 100644
index 3848479..0000000
--- a/bahmni_account/doc/ChangeLog.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-1. New fields added to account.invoice for applying discounts on invoices.
- 1. Discount Type : None, Fixed, Percentage
- 2. Discount : Total discount amount getting applied.
- 3. Discount Percentage : If percentage type is selected, then for defining percentage.
- - if discount type is selected as percentage, then discount field will be readonly,
- as discount amount will get computed based on given percentage.
- 4. Discount Account Head : Account from/to which discount amount will get credited or debited.
-2. on change method is defined for discount percentage and invoice lines, to compute discount amount, when type percetage is selected.
-3. Customer Invoices form is inherited, and footer is defined completely in new way,
- as default footer class was not making form look good.
-4. compute_amount method is overridden to change the logic of computing total of invoice, i.e. deduct discount amount from total.
-5. create method of account_invoice_line is inherited to set value of discount field,
- when invoice is created through Create Invoice button on Sale Order form.
- As method which is getting called through that button, is creating invoice object first
- and then one-by-one invoice lines are getting created.
- 6. rouding.off class defined to set round_off_amount value in account_invoice and sale_order.
- for calculating this value, configuration is provided to user under Sales > Configuration > Settings menu,
- where user can set Round Off Value, this is the amount to which value has to get rounded off.
-
\ No newline at end of file
diff --git a/bahmni_account/doc/imp_points.txt b/bahmni_account/doc/imp_points.txt
deleted file mode 100644
index 52e8619..0000000
--- a/bahmni_account/doc/imp_points.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-* rounding.off class is kept in bahmni_account module, as it is used in account_invoice and sale_order class.
- bahmni_sale already has dependency of bahmni_account module, hence this class can be accessed in that module.
- vice-versa won't happen; as it will be a round dependency.
\ No newline at end of file
diff --git a/bahmni_account/models/__init__.py b/bahmni_account/models/__init__.py
index a0a3d02..5eef738 100644
--- a/bahmni_account/models/__init__.py
+++ b/bahmni_account/models/__init__.py
@@ -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
diff --git a/bahmni_account/models/account_config_settings.py b/bahmni_account/models/account_config_settings.py
deleted file mode 100644
index 203ad3f..0000000
--- a/bahmni_account/models/account_config_settings.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-from odoo import models, fields, api
-
-
-class AccountConfigSettings(models.TransientModel):
- _inherit = 'res.config.settings'
-
- round_off_by = fields.Float(string="Round off by", related="company_id.round_off_by")
-
- def set_round_off_by_defaults(self):
- return self.env['ir.values'].sudo().set_default(
- 'res.config.settings', 'round_off_by', self.round_off_by)
-
-
diff --git a/bahmni_account/models/account_invoice.py b/bahmni_account/models/account_invoice.py
index cf66ea0..08f3424 100644
--- a/bahmni_account/models/account_invoice.py
+++ b/bahmni_account/models/account_invoice.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
from odoo.exceptions import UserError, ValidationError
import logging
@@ -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')],
@@ -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):
@@ -93,139 +71,42 @@ def _find_batch(self, product, qty, location, picking):
message = ("Auto validation Failed
Reason: There are no Batches/Serial no's available for %s 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):
diff --git a/bahmni_account/models/account_invoice_line.py b/bahmni_account/models/account_invoice_line.py
index cf0480d..9e5b69c 100644
--- a/bahmni_account/models/account_invoice_line.py
+++ b/bahmni_account/models/account_invoice_line.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, api, fields
diff --git a/bahmni_account/models/account_payment.py b/bahmni_account/models/account_payment.py
deleted file mode 100644
index f14bb25..0000000
--- a/bahmni_account/models/account_payment.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-from itertools import groupby
-from odoo import models, fields, api
-
-class AccountPayment(models.Model):
- _inherit = 'account.payment'
-
- @api.onchange('partner_id', 'amount')
- def _calculate_balances(self):
- if(self.state != 'posted'):
- partner = self.partner_id
- balance = partner.credit or partner.debit
- self.balance_before_pay = balance
- self.total_balance = balance - self.amount
-
- @api.onchange('invoice_ids')
- def onchange_partner_id(self):
- if self.invoice_ids:
- bill_amount = 0
- for inv in self.invoice_ids:
- bill_amount += inv.amount_total
- self.bill_amount = bill_amount
-
- @api.onchange('payment_type')
- def _onchange_payment_type(self):
- if not self.invoice_ids:
- # Set default partner type for the payment type
- if self.payment_type == 'inbound':
- self.partner_type = 'customer'
- elif self.payment_type == 'outbound':
- self.partner_type = 'supplier'
- else:
- self.partner_type = False
- # Set payment method domain
- res = self._onchange_journal()
- if not res.get('domain', {}):
- res['domain'] = {}
- res['domain']['journal_id'] = self.payment_type == 'inbound' and [('at_least_one_inbound', '=', True)] or self.payment_type == 'outbound' and [('at_least_one_outbound', '=', True)] or []
- return res
-
- balance_before_pay = fields.Float(compute=_calculate_balances,
- string="Balance before pay")
- total_balance = fields.Float(compute=_calculate_balances,
- string="Total Balance")
- invoice_id = fields.Many2one('account.invoice', string='Invoice')
- bill_amount = fields.Float(string="Bill Amount")
diff --git a/bahmni_account/models/res_company.py b/bahmni_account/models/res_company.py
index 17ac2e4..b57016c 100644
--- a/bahmni_account/models/res_company.py
+++ b/bahmni_account/models/res_company.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields
diff --git a/bahmni_account/models/res_partner.py b/bahmni_account/models/res_partner.py
deleted file mode 100644
index e9810b3..0000000
--- a/bahmni_account/models/res_partner.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-from odoo import models, fields
-
-
-class ResPartner(models.Model):
- _inherit = 'res.partner'
-
- initials = fields.Char(string="Initials")
diff --git a/bahmni_account/models/rounding_off.py b/bahmni_account/models/rounding_off.py
index e0a15cc..307f70c 100644
--- a/bahmni_account/models/rounding_off.py
+++ b/bahmni_account/models/rounding_off.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
class RoundingOff(models.Model):
diff --git a/bahmni_account/report/__init__.py b/bahmni_account/report/__init__.py
deleted file mode 100644
index a3eab91..0000000
--- a/bahmni_account/report/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# -*- coding: utf-8 -*-
-from . import account_count_report
-from . import account_report
diff --git a/bahmni_account/report/account_count_report.py b/bahmni_account/report/account_count_report.py
deleted file mode 100644
index bc63e42..0000000
--- a/bahmni_account/report/account_count_report.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- coding: utf-8 -*-
-from odoo import models, fields, api
-from odoo.tools import drop_view_if_exists
-from odoo.exceptions import Warning
-
-
-class AccountCountReport(models.Model):
- _name = 'account.count.report'
- _auto = False
- _description = "Count of account heads in sale orders over a period"
-
- count = fields.Integer(string="Count", readonly=True)
- date = fields.Date(string="Date", readonly=True)
- account_id = fields.Many2one('account.account', string="Account")
-
- # ~ @api.model_cr
- def init(self):
- drop_view_if_exists(self.env.cr, 'account_count_report')
- self.env.cr.execute("""
- create or replace view account_count_report as (
- select
- concat(ail.account_id, '_', ai.date) as id,
- ai.date as date,
- ail.account_id as account_id,
- count(*) as count
- from account_move ai, account_move_line ail
- where
- ail.move_id = ai.id
- --and ai.type != 'out_refund'
- group by ail.account_id, ai.date
- )""")
-
- # ~ @api.multi
- def unlink(self):
- raise Warning('You cannot delete any record!')
diff --git a/bahmni_account/report/account_count_report.xml b/bahmni_account/report/account_count_report.xml
deleted file mode 100644
index 79248e9..0000000
--- a/bahmni_account/report/account_count_report.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
- account.count.report.tree
- account.count.report
-
-
-
-
-
-
-
-
-
-
- account.count.report.filter
- account.count.report
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Accounts Count Report
- ir.actions.act_window
- account.count.report
- tree,form
-
-
- {}
-
-
-
-
-
-
diff --git a/bahmni_account/report/account_report.py b/bahmni_account/report/account_report.py
deleted file mode 100644
index 3de56b3..0000000
--- a/bahmni_account/report/account_report.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- coding: utf-8 -*-
-from odoo import models, fields, api
-from odoo.tools import drop_view_if_exists
-
-
-class AccountReport(models.Model):
- _name ='bahmni.account.report'
- _inherit = 'account.report'
- _description = "Account reports for actual & received amount"
- _auto = False
-
- actual_amount = fields.Integer(string="Expenses")
- amount_received = fields.Integer(string="Collections")
- date = fields.Date(string="Date")
- account_id = fields.Many2one('account.account', string="Account Head")
-
- # ~ @api.model_cr
- def init(self):
- drop_view_if_exists(self.env.cr, 'bahmni_account_report')
- self.env.cr.execute("""
- create or replace view bahmni_account_report as (
- (select id,date,account_id, sum(actual_amount) as actual_amount,sum(amount_received) as amount_received
- from (
- SELECT
- pg_catalog.concat(ail.account_id, '_', ai.date, '_', ai.move_type) AS id,ai.id as invoice_id,
- ai.date AS date,
- ail.account_id,
- CASE
- WHEN ai.move_type = 'out_refund' THEN 0
- ELSE sum(ail.price_subtotal)
- END AS actual_amount,
- CASE
- WHEN ai.move_type = 'out_refund' THEN sum(
- (-ail.price_subtotal) * (ai.amount_total / (ai.amount_tax + ai.amount_untaxed)))
- ELSE sum(ail.price_subtotal * (ai.amount_total / (ai.amount_tax + ai.amount_untaxed)))
- END AS amount_received
- FROM account_move ai, account_move_line ail
- WHERE ail.move_id = ai.id AND (ai.amount_tax + ai.amount_untaxed) <> 0 AND state = 'paid'
- GROUP BY ail.account_id, ai.date, ai.move_type, ai.id
- UNION
- SELECT
- pg_catalog.concat(ail.account_id, '_', ai.date, '_', ai.move_type) AS id,ai.id as invoice_id,
- ai.date AS date,
- ail.account_id,
- CASE
- WHEN ai.move_type = 'out_refund' THEN 0
- ELSE max(ai.amount_total)
- END AS actual_amount,
- CASE
- WHEN ai.move_type = 'out_refund' THEN max(ai.amount_total) * -1
- ELSE max(ai.amount_total)
- END AS amount_received
- FROM account_move ai, account_move_line ail
- WHERE ail.move_id = ai.id AND (ai.amount_tax + ai.amount_untaxed) = 0 AND state = 'paid'
- and ail.account_id not in
- (select id from account_account where name in ('FINE','Discount','Overcharge'))
- GROUP BY ail.account_id, ai.date, ai.move_type,ai.id
- UNION
- SELECT
- pg_catalog.concat(ail.account_id, '_', ai.date, '_', ai.move_type) AS id,ai.id as invoice_id,
- ai.date AS date,
- ail.account_id,
- CASE
- WHEN ai.move_type = 'out_refund' THEN 0
- ELSE sum(ai.amount_total)
- END AS actual_amount,
- CASE
- WHEN ai.move_type = 'out_refund' THEN sum(-ai.amount_total)
- ELSE sum(ai.amount_total)
- END AS amount_received
- FROM account_move ai, account_move_line ail
- WHERE ail.move_id = ai.id AND (ai.amount_tax + ai.amount_untaxed) = 0 AND state = 'paid'
- and ail.account_id in
- (select id from account_account where name in ('FINE','Discount','Overcharge'))
- GROUP BY ail.account_id, ai.date, ai.move_type,ai.id
- ) as r group by id,date,account_id)
- )""")
-
diff --git a/bahmni_account/report/account_report.xml b/bahmni_account/report/account_report.xml
deleted file mode 100644
index 838cf4b..0000000
--- a/bahmni_account/report/account_report.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
- account.report.tree
- bahmni.account.report
-
-
-
-
-
-
-
-
-
-
-
- account.report.filter
- bahmni.account.report
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Account Report
- ir.actions.act_window
- bahmni.account.report
- tree,form
-
-
- {}
-
-
-
-
-
diff --git a/bahmni_account/report/report_invoice_inherit.xml b/bahmni_account/report/report_invoice_inherit.xml
deleted file mode 100644
index 7256f6b..0000000
--- a/bahmni_account/report/report_invoice_inherit.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
-
-
-
-
-
-
- Invoice
- PRO-FORMA
- Draft Invoice
- Cancelled Invoice
- Refund
- Vendor Refund
- Vendor Bill
-
-
-
-
-
-
-
-
-
-
-
- Description |
- Source Document |
- Quantity |
- Batch No |
- Expiry Date |
- Unit Price |
- Disc.(%) |
- Taxes |
- Tax Excluded Price |
-
-
-
-
- |
- |
-
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
-
- Subtotal |
-
-
- |
-
-
-
- |
-
-
- |
-
-
-
- Total |
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
- Tax |
- Base |
- Amount |
-
-
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-
- Comment:
-
-
-
-
-
-
- Fiscal Position Remark:
-
-
-
-
-
-
diff --git a/bahmni_account/views/account_config_settings.xml b/bahmni_account/views/account_config_settings.xml
deleted file mode 100644
index 13d12b9..0000000
--- a/bahmni_account/views/account_config_settings.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- inherit.view.account.config.settings
- res.config.settings
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bahmni_account/views/account_invoice_view.xml b/bahmni_account/views/account_invoice_view.xml
index 1e9324d..36be75c 100644
--- a/bahmni_account/views/account_invoice_view.xml
+++ b/bahmni_account/views/account_invoice_view.xml
@@ -8,106 +8,46 @@
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
+
+
+
+
-
-
-
@@ -141,81 +81,6 @@
-
-
- inherit.invoice.supplier.form
- account.move
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/bahmni_account/views/account_payment.xml b/bahmni_account/views/account_payment.xml
deleted file mode 100644
index dcab769..0000000
--- a/bahmni_account/views/account_payment.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
- view.account.payment.form.inherit
- account.payment
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- view.register.payment.inherit
- account.payment
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bahmni_account/views/bahmni_account.xml b/bahmni_account/views/bahmni_account.xml
deleted file mode 100644
index 767df39..0000000
--- a/bahmni_account/views/bahmni_account.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/bahmni_api_feed/__init__.py b/bahmni_api_feed/__init__.py
index a0fdc10..0650744 100644
--- a/bahmni_api_feed/__init__.py
+++ b/bahmni_api_feed/__init__.py
@@ -1,2 +1 @@
-# -*- coding: utf-8 -*-
from . import models
diff --git a/bahmni_api_feed/__manifest__.py b/bahmni_api_feed/__manifest__.py
index 36769e2..3b3cf22 100644
--- a/bahmni_api_feed/__manifest__.py
+++ b/bahmni_api_feed/__manifest__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
{
'name': 'Bahmni API Feed',
'version': '1.0',
diff --git a/bahmni_api_feed/models/__init__.py b/bahmni_api_feed/models/__init__.py
index 69ea7d5..a4a1085 100644
--- a/bahmni_api_feed/models/__init__.py
+++ b/bahmni_api_feed/models/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from . import api_event_worker
from . import event_records
from . import reference_data_service
diff --git a/bahmni_api_feed/models/api_event_worker.py b/bahmni_api_feed/models/api_event_worker.py
index f7b7b90..77ea1ac 100644
--- a/bahmni_api_feed/models/api_event_worker.py
+++ b/bahmni_api_feed/models/api_event_worker.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
import logging
import json
diff --git a/bahmni_api_feed/models/drug_data_service.py b/bahmni_api_feed/models/drug_data_service.py
index a86022d..66c123a 100644
--- a/bahmni_api_feed/models/drug_data_service.py
+++ b/bahmni_api_feed/models/drug_data_service.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import json
import logging
diff --git a/bahmni_api_feed/models/event_records.py b/bahmni_api_feed/models/event_records.py
index 77fde19..80c4ade 100644
--- a/bahmni_api_feed/models/event_records.py
+++ b/bahmni_api_feed/models/event_records.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
@@ -13,4 +12,4 @@ class EventRecords(models.Model):
category = fields.Char(string="Category", translate=True, required=True)
timestamp = fields.Datetime(string="Timestamp", required=True)
uri = fields.Char(string="URI", translate=True)
- object = fields.Text(string="SerializedContents", required=True)
\ No newline at end of file
+ object = fields.Text(string="SerializedContents", required=True)
diff --git a/bahmni_api_feed/models/order_picking_type_mapping.py b/bahmni_api_feed/models/order_picking_type_mapping.py
index eecde9d..c7711eb 100644
--- a/bahmni_api_feed/models/order_picking_type_mapping.py
+++ b/bahmni_api_feed/models/order_picking_type_mapping.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
@@ -10,20 +9,6 @@ class OrderType(models.Model):
_sql_constraints = [('unique_name', 'unique(name)',
'Order type with this name already exists!')]
-''' @api.model
- def create(self, vals):
- if vals.get('name'):
- name = vals['name'].capitalize()
- vals.update({'name': name})
- return super(OrderType, self).create(vals)
-
-
- def write(self, vals):
- if vals.get('name'):
- name = vals['name'].capitalize()
- vals.update({'name': name})
- return super(OrderType, self).write(vals)
-'''
class OrderPickingTypeMapping(models.Model):
_name = 'order.picking.type.mapping'
diff --git a/bahmni_api_feed/models/order_save_service.py b/bahmni_api_feed/models/order_save_service.py
index 7de8cee..ec25766 100644
--- a/bahmni_api_feed/models/order_save_service.py
+++ b/bahmni_api_feed/models/order_save_service.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime
import json
from itertools import groupby
@@ -77,6 +76,8 @@ def _get_shop_and_location_id(self, orderType, location_name, order_type_record)
#return False, False
order_type = self.env['order.type'].sudo().search([('name', '=', orderType)], limit=1)
location_rec = self.env['stock.location'].sudo().search([('name', '=', location_name)], limit=1)
+ if not location_rec:
+ raise UserError("Location(Sales shop) does not exist in ERP")
shop_list_with_order_type = OrderTypeShopMap.sudo().create({
"order_type": order_type.id if order_type else self.env['order.type'].sudo().create({'name': OrderType}),
"location_name": location_name,
diff --git a/bahmni_api_feed/models/order_type.py b/bahmni_api_feed/models/order_type.py
index ada49dd..7ad05e9 100644
--- a/bahmni_api_feed/models/order_type.py
+++ b/bahmni_api_feed/models/order_type.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
diff --git a/bahmni_api_feed/models/order_type_shop_map.py b/bahmni_api_feed/models/order_type_shop_map.py
index e8246b9..1a96e5c 100755
--- a/bahmni_api_feed/models/order_type_shop_map.py
+++ b/bahmni_api_feed/models/order_type_shop_map.py
@@ -1,4 +1,3 @@
-
from odoo import fields, models, api, _
class order_type_shop_map(models.Model):
diff --git a/bahmni_api_feed/models/product_uom_service.py b/bahmni_api_feed/models/product_uom_service.py
index 9b93624..2146b8a 100644
--- a/bahmni_api_feed/models/product_uom_service.py
+++ b/bahmni_api_feed/models/product_uom_service.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import json
import logging
diff --git a/bahmni_api_feed/models/reference_data_service.py b/bahmni_api_feed/models/reference_data_service.py
index e640465..ce11dd6 100644
--- a/bahmni_api_feed/models/reference_data_service.py
+++ b/bahmni_api_feed/models/reference_data_service.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import json
import logging
@@ -53,6 +52,8 @@ def _fill_data(self, vals, category=None):
def _get_category_hierarchy(self, category):
if category == 'Radiology':
return ["Services", "All Products"]
+ elif category == 'Test':
+ return ["Lab", "Services", "All Products"]
elif category == 'Panel':
return ["Lab", "Services", "All Products"]
else:
diff --git a/bahmni_api_feed/models/res_company.py b/bahmni_api_feed/models/res_company.py
index 93e0e38..60b19b1 100644
--- a/bahmni_api_feed/models/res_company.py
+++ b/bahmni_api_feed/models/res_company.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields
@@ -24,4 +23,4 @@ class ResCompany(models.Model):
"""
- _header_a4 = _header_main_wo_placeholders
\ No newline at end of file
+ _header_a4 = _header_main_wo_placeholders
diff --git a/bahmni_api_feed/models/res_users.py b/bahmni_api_feed/models/res_users.py
index 5f3f92e..d8906f1 100644
--- a/bahmni_api_feed/models/res_users.py
+++ b/bahmni_api_feed/models/res_users.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import odoo
from odoo import models, fields, api
diff --git a/bahmni_api_feed/models/syncable_units_mapping.py b/bahmni_api_feed/models/syncable_units_mapping.py
index aea4eea..f5dff9f 100644
--- a/bahmni_api_feed/models/syncable_units_mapping.py
+++ b/bahmni_api_feed/models/syncable_units_mapping.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields
diff --git a/bahmni_api_feed/wizard/__init__.py b/bahmni_api_feed/wizard/__init__.py
deleted file mode 100644
index 052990e..0000000
--- a/bahmni_api_feed/wizard/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# -*- coding: utf-8 -*-
-from . import stock_location_product_dhis2
diff --git a/bahmni_api_feed/wizard/stock_location_product_dhis2.py b/bahmni_api_feed/wizard/stock_location_product_dhis2.py
deleted file mode 100644
index ff9e236..0000000
--- a/bahmni_api_feed/wizard/stock_location_product_dhis2.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# -*- coding: utf-8 -*-
-import base64
-import datetime
-from dateutil.relativedelta import relativedelta
-
-from odoo import models, fields, api
-from odoo.addons.web.controllers.main import CSVExport
-from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF, DEFAULT_SERVER_DATETIME_FORMAT as DTF
-
-
-class StockLocationProductDhis2(models.TransientModel):
- _name = 'stock.location.product.dhis2'
- _description = "DHIS2 Export product stock at location"
-
- MONTHS = [(1, "Jan"), (2, "Feb"), (3, "Mar"), (4, "Apr"), (5, "May"),
- (6, "Jun"), (7, "Jul"),
- (8, "Aug"), (9, "Sep"), (10, "Oct"), (11, "Nov"), (12, "Dec")]
-
- FIELDS = ['dhis2_code', 'virtual_available']
- HEADERS = ['dataelement', 'period', 'orgunit', 'categoryoptioncombo',
- 'value', 'storedby', 'lastupdated', 'comment', 'followup']
-
- @api.model
- def _get_available_years_in_system(self):
- '''this method will return selection values for the years,
- for which entries are available in the system'''
- res = []
- date_today = datetime.date.today()
- start_date_stock_move = self.env['stock.move'].search([], order='date asc', limit=1).date
- if start_date_stock_move:
- start_date_stock_move = datetime.datetime.strptime(start_date_stock_move, DTF).date()
- start_date_account_move = self.env['account.move'].search([], order='date asc', limit=1).date
- if start_date_account_move:
- start_date_account_move = datetime.datetime.strptime(start_date_account_move, DF).date()
- if start_date_account_move and start_date_stock_move:
- start_year = False
- if start_date_stock_move < start_date_account_move:
- start_year = start_date_stock_move.year
- else:
- start_year = start_date_account_move.year
- if (str(start_year), start_year) not in res:
- res.append((str(start_year), start_year))
- if date_today.year > start_year:
- for i in range(start_year, date_today.year):
- if (str(i+1), i+1) not in res:
- res.append((str(i+1), i+1))
- else:
- if start_date_account_move:
- res.append((str(start_date_account_move.year), start_date_account_move.year))
- elif start_date_stock_move:
- res.append((str(start_date_stock_move.year), start_date_stock_move.year))
- else:
- res.append((str(date_today.year), date_today.year))
- return res
-
- from_date = fields.Datetime(string="From Date")
- to_date = fields.Datetime(string="To Date")
- month = fields.Selection(MONTHS, string="Month")
- year = fields.Selection(_get_available_years_in_system, string='Year')
- data = fields.Binary(string="CSV file")
- data_fname = fields.Char(string="File Name", default="stock_product_location.csv")
- state = fields.Selection([('choose', 'choose'), ('get', 'get')],
- string="State", default="choose")
-
- def action_generate_csv(self):
- self.ensure_one()
- dialog_box_data = self.read(['month', 'year', 'to_date', 'from_date'])[0]
- export_data = self._get_export_data(dialog_box_data)
- csv_data = CSVExport().from_data(self.HEADERS, export_data)
-
- self.write({'data': base64.encodestring(csv_data),
- 'state': 'get'})
- return {
- 'type': 'ir.actions.act_window',
- 'res_model': 'stock.location.product.dhis2',
- 'view_mode': 'form',
- 'view_type': 'form',
- 'res_id': self.id,
- 'views': [(False, 'form')],
- 'target': 'new',
- }
-
- @api.model
- def _get_export_data(self, dialog_box_data):
- product_model = self.env['product.product']
- domain = [('type', '<>', 'service')]
- product_search_context = self.with_context(self._context)._create_product_search_context(dialog_box_data)
- product_obj = product_model.with_context(product_search_context).search(domain)
-
- export_data = product_obj.export_data(self.FIELDS).get('datas', [])
- company = self.env['res.company'].browse(self._context.get('active_id'))
- orgunit = company.dhis2_code
- period = datetime.date(year=int(dialog_box_data['year']), month=int(dialog_box_data['month']), day=1).strftime("%Y%m")
- modified_export_data = []
- for row in export_data:
- modified_row = []
- modified_row.append(row[0]) #dataelement
- modified_row.append(period)
- modified_row.append(orgunit)
- modified_row.append(None) #categoryoptioncombo
- modified_row.append(row[1]) #value
- modified_row.append(None) #storedby
- modified_row.append(None) #lastupdated
- modified_row.append(None) #comment
- modified_row.append(None) #followup
- modified_export_data.append(modified_row)
- return modified_export_data
-
- def _create_product_search_context(self, data):
- first_day_of_month = datetime.date(year=int(data['year']), month=int(data['month']), day=1)
- first_day_of_next_month = first_day_of_month + relativedelta(months=1)
- return {
- 'from_date': data['from_date'],
- 'to_date': datetime.datetime.strftime(first_day_of_next_month, DF),
- }
diff --git a/bahmni_api_feed/wizard/stock_location_product_dhis2.xml b/bahmni_api_feed/wizard/stock_location_product_dhis2.xml
deleted file mode 100644
index c7a1800..0000000
--- a/bahmni_api_feed/wizard/stock_location_product_dhis2.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- form.stock.location.product.dhis2
- stock.location.product.dhis2
-
-
-
-
-
-
-
-
diff --git a/bahmni_product/models/__init__.py b/bahmni_product/models/__init__.py
index 6ee70a9..58b292a 100644
--- a/bahmni_product/models/__init__.py
+++ b/bahmni_product/models/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from . import product_category
from . import product_uom
from . import res_partner
diff --git a/bahmni_product/models/product.py b/bahmni_product/models/product.py
index 1f27616..0181450 100644
--- a/bahmni_product/models/product.py
+++ b/bahmni_product/models/product.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from copy import copy
from datetime import datetime, date
@@ -37,6 +36,7 @@ def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False
domain_move_out += [('restrict_partner_id', '=', owner_id)]
if package_id:
domain_quant += [('package_id', '=', package_id)]
+# if dates_in_the_past:
domain_move_in_done = list(domain_move_out)
domain_move_out_done = list(domain_move_in)
domain_quant_actual_stock = copy(domain_quant)
@@ -59,6 +59,7 @@ def _compute_quantities_dict(self, lot_id, owner_id, package_id, from_date=False
moves_out_res = dict((item['product_id'][0], item['product_qty']) for item in Move.read_group(domain_move_out_todo, ['product_id', 'product_qty'], ['product_id'], orderby='id'))
quants_res = dict((item['product_id'][0], item['quantity']) for item in Quant.read_group(domain_quant, ['product_id', 'quantity'], ['product_id'], orderby='id'))
quants_res_actual_stock = dict((item['product_id'][0], item['quantity']) for item in Quant.read_group(domain_quant_actual_stock, ['product_id', 'quantity'], ['product_id'], orderby='id'))
+# if dates_in_the_past:
# Calculate the moves that were done before now to calculate back in time (as most questions will be recent ones)
if to_date:
domain_move_in_done = [('state', '=', 'done'), ('date', '>', to_date)] + domain_move_in_done
@@ -116,6 +117,8 @@ def create(self, vals):
product = super(ProductProduct, self.with_context(create_product_product=True,
mrp=vals.get('mrp'))).create(vals)
# When a unique variant is created from tmpl then the standard price is set by _set_standard_price
+ # ~ if not (self.env.context.get('create_from_tmpl') and len(product.product_tmpl_id.product_variant_ids) == 1):
+ # ~ product._set_standard_price(vals.get('standard_price') or 0.0)
return product
def write(self, vals):
@@ -149,9 +152,11 @@ def _compute_quantities(self):
template.actual_stock = res[template.id]['actual_stock']
def _compute_quantities_dict(self):
+
variants_available = {
p['id']: p for p in self.product_variant_ids._origin.read(['qty_available', 'virtual_available', 'incoming_qty', 'outgoing_qty','actual_stock'])
}
+ print("variants_available",variants_available)
prod_available = {}
for template in self:
qty_available = 0
@@ -160,6 +165,7 @@ def _compute_quantities_dict(self):
outgoing_qty = 0
actual_stock = 0
for p in template.product_variant_ids:
+ print("p.id",p.id)
qty_available += variants_available[p.id]["qty_available"]
virtual_available += variants_available[p.id]["virtual_available"]
incoming_qty += variants_available[p.id]["incoming_qty"]
diff --git a/bahmni_product/models/product_category.py b/bahmni_product/models/product_category.py
index 315e73d..64ea074 100644
--- a/bahmni_product/models/product_category.py
+++ b/bahmni_product/models/product_category.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import uuid
from odoo import models, fields, api
@@ -14,3 +13,4 @@ def create(self, vals):
vals.update({'uuid': uuid.uuid4()})
return super(ProductCategory, self).create(vals)
+
diff --git a/bahmni_product/models/product_supplierinfo.py b/bahmni_product/models/product_supplierinfo.py
index fd5db68..0b13056 100644
--- a/bahmni_product/models/product_supplierinfo.py
+++ b/bahmni_product/models/product_supplierinfo.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
diff --git a/bahmni_product/models/product_uom.py b/bahmni_product/models/product_uom.py
index 0523956..c88d9b4 100644
--- a/bahmni_product/models/product_uom.py
+++ b/bahmni_product/models/product_uom.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import uuid
from odoo import models, fields, api
diff --git a/bahmni_product/models/res_partner.py b/bahmni_product/models/res_partner.py
index e456af1..4949315 100644
--- a/bahmni_product/models/res_partner.py
+++ b/bahmni_product/models/res_partner.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields
diff --git a/bahmni_purchase/__manifest__.py b/bahmni_purchase/__manifest__.py
index 9704d29..6b9a5d6 100644
--- a/bahmni_purchase/__manifest__.py
+++ b/bahmni_purchase/__manifest__.py
@@ -13,7 +13,7 @@
'images': [],
'depends': ['purchase', 'bahmni_product', 'bahmni_stock'],
'data': [
- 'views/purchase_views.xml',
+ 'views/purchase_views.xml',
'views/product_view.xml',
'views/price_markup_table_view.xml'],
'demo': [],
diff --git a/bahmni_purchase/models/__init__.py b/bahmni_purchase/models/__init__.py
index 50cc764..406c41e 100644
--- a/bahmni_purchase/models/__init__.py
+++ b/bahmni_purchase/models/__init__.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
from . import purchase_order_line
from . import product
from . import price_markup_table
-# ~ from . import stock_pack_operation_lot
diff --git a/bahmni_purchase/models/price_markup_table.py b/bahmni_purchase/models/price_markup_table.py
index abfeacb..36d5cba 100644
--- a/bahmni_purchase/models/price_markup_table.py
+++ b/bahmni_purchase/models/price_markup_table.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import fields, models
diff --git a/bahmni_purchase/models/product.py b/bahmni_purchase/models/product.py
index e32b65c..a61bb9f 100644
--- a/bahmni_purchase/models/product.py
+++ b/bahmni_purchase/models/product.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields
diff --git a/bahmni_purchase/models/purchase_order_line.py b/bahmni_purchase/models/purchase_order_line.py
index d412820..3400772 100644
--- a/bahmni_purchase/models/purchase_order_line.py
+++ b/bahmni_purchase/models/purchase_order_line.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime
from odoo import models, fields, api
from odoo import SUPERUSER_ID
diff --git a/bahmni_purchase/models/stock_pack_operation_lot.py b/bahmni_purchase/models/stock_pack_operation_lot.py
deleted file mode 100644
index 1626ea3..0000000
--- a/bahmni_purchase/models/stock_pack_operation_lot.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-from odoo import models, fields, api
-import odoo.addons.decimal_precision as dp
-
-
-class StockPackOperationLot(models.Model):
- _inherit = 'stock.pack.operation.lot'
-
- @api.model
- def default_get(self, fields):
- res = {}
- ctx = self._context.copy()
- operation_id = ctx.get('operation_id')
- # get cost price of product from purchase order line, linked with stock_move
- if operation_id:
- pack_operation = self.env['stock.pack.operation'].browse(operation_id)
- mv_op_link_ids = self.env['stock.move.operation.link'].search([('operation_id', '=', operation_id)],limit=1)
-
- if mv_op_link_ids:
- for link in mv_op_link_ids:
- res.update({'move_id': link.move_id.id})
- purchase_line = link.move_id.purchase_line_id
- amount_tax = 0.0
- if pack_operation.picking_id.company_id.tax_calculation_rounding_method == 'round_globally':
- taxes = purchase_line.taxes_id.compute_all(purchase_line.price_unit, purchase_line.order_id.currency_id,
- 1.0, pack_operation.product_id, pack_operation.picking_id.partner_id)
- amount_tax += sum(t.get('amount', 0.0) for t in taxes.get('taxes', []))
- else:
- amount_tax += purchase_line.price_tax
- res.update({'cost_price': purchase_line.price_unit + amount_tax})
- # calculate sale price, based on markup percentage defined in price markup table
- if res.get('cost_price'):
- cost_price = res.get('cost_price')
- markup_table_line = self.env['price.markup.table'].search([('lower_price', '<', cost_price),
- '|', ('higher_price', '>=', cost_price),
- ('higher_price', '=', 0)])
- if markup_table_line and len(markup_table_line)==1:
- res.update({'sale_price': cost_price + (cost_price * markup_table_line.markup_percentage / 100)})
- return res
-
- sale_price = fields.Float(string="Sale Price", digits=dp.get_precision('Product Price'))
- cost_price = fields.Float(string="Cost Price", digits=dp.get_precision('Product Price'))
- mrp = fields.Float(string="MRP", digits=dp.get_precision('Product Price'))
- expiry_date = fields.Date(string="Expiry Date", digits=dp.get_precision('Product Price'))
- move_id = fields.Many2one('stock.move',
- string="Stock Move",
- help="This field is used to track, which all move_ids are utilized to fetch cost_price")
-
- @api.onchange('cost_price')
- def onchange_cost_price(self):
- for record in self:
- if record.cost_price:
- markup_table_line = self.env['price.markup.table'].search([('lower_price', '<', record.cost_price),
- '|', ('higher_price', '>=', record.cost_price),
- ('higher_price', '=', 0)])
- if markup_table_line and len(markup_table_line)==1:
- self.sale_price = record.cost_price + (record.cost_price * markup_table_line.markup_percentage / 100)
diff --git a/bahmni_purchase/views/price_markup_table_view.xml b/bahmni_purchase/views/price_markup_table_view.xml
index c464e22..96b7352 100644
--- a/bahmni_purchase/views/price_markup_table_view.xml
+++ b/bahmni_purchase/views/price_markup_table_view.xml
@@ -19,6 +19,5 @@
tree,form
-
+
diff --git a/bahmni_purchase/views/stock_pack_operation_view.xml b/bahmni_purchase/views/stock_pack_operation_view.xml
deleted file mode 100644
index cc56109..0000000
--- a/bahmni_purchase/views/stock_pack_operation_view.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- view.pack.operation.lot.form.inherit
- stock.pack.operation
-
-
-
-
-
-
- {'product_id': product_id, 'operation_id': id,
- 'pack_lot_ids': pack_lot_ids}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bahmni_sale/__init__.py b/bahmni_sale/__init__.py
index 408a600..9b42961 100644
--- a/bahmni_sale/__init__.py
+++ b/bahmni_sale/__init__.py
@@ -1,3 +1,2 @@
-# -*- coding: utf-8 -*-
from . import models
from . import wizard
diff --git a/bahmni_sale/__manifest__.py b/bahmni_sale/__manifest__.py
index 8e6cf18..382b786 100644
--- a/bahmni_sale/__manifest__.py
+++ b/bahmni_sale/__manifest__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
{
'name': 'Bahmni Sale',
'version': '1.0',
diff --git a/bahmni_sale/doc/ChangeLog.txt b/bahmni_sale/doc/ChangeLog.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/bahmni_sale/doc/imp_points.txt b/bahmni_sale/doc/imp_points.txt
deleted file mode 100644
index f02e143..0000000
--- a/bahmni_sale/doc/imp_points.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-* def _create_invoices need not to be overridden, as this method is called only when down payments are done.
- and invoice is made for down payment, hence discount has not to be carry forward to invoice,
- if any discount is applicable, user has to update that manually.
\ No newline at end of file
diff --git a/bahmni_sale/models/__init__.py b/bahmni_sale/models/__init__.py
index 3fb9252..d5a0025 100644
--- a/bahmni_sale/models/__init__.py
+++ b/bahmni_sale/models/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from . import village_master
from . import res_partner
from . import sale_order
diff --git a/bahmni_sale/models/res_company.py b/bahmni_sale/models/res_company.py
index e7d30af..34f2073 100644
--- a/bahmni_sale/models/res_company.py
+++ b/bahmni_sale/models/res_company.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
diff --git a/bahmni_sale/models/res_partner.py b/bahmni_sale/models/res_partner.py
index 782c8ae..d3999f1 100644
--- a/bahmni_sale/models/res_partner.py
+++ b/bahmni_sale/models/res_partner.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
diff --git a/bahmni_sale/models/sale_config_settings.py b/bahmni_sale/models/sale_config_settings.py
index 5b03c03..3525358 100644
--- a/bahmni_sale/models/sale_config_settings.py
+++ b/bahmni_sale/models/sale_config_settings.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
diff --git a/bahmni_sale/models/sale_order.py b/bahmni_sale/models/sale_order.py
index de7e0f3..70e0304 100644
--- a/bahmni_sale/models/sale_order.py
+++ b/bahmni_sale/models/sale_order.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime, date
from lxml import etree
@@ -16,7 +15,7 @@ class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.depends('order_line.price_total', 'discount', 'chargeable_amount')
- def _amount_all(self):
+ def _compute_amounts(self):
"""
Compute the total amounts of the SO.
"""
@@ -32,24 +31,44 @@ def _amount_all(self):
else:
amount_tax += line.price_tax
amount_total = amount_untaxed + amount_tax
+
+ if self.discount_percentage:
+ tot_discount = amount_total * self.discount_percentage / 100
+ else:
+ tot_discount = self.discount
+
if order.chargeable_amount > 0.0:
discount = amount_total - order.chargeable_amount
else:
- discount = order.discount
+ discount = tot_discount
amount_total = amount_total - discount
- round_off_amount = self.env['rounding.off'].round_off_value_to_nearest(amount_total)
+ round_off_amount = self.env['rounding.off'].round_off_value_to_nearest(amount_total)
+ if order.pricelist_id:
+ amt_untax = order.pricelist_id.currency_id.round(amount_untaxed)
+ amt_tax = order.pricelist_id.currency_id.round(amount_tax)
+ else:
+ amt_untax = 0.00
+ amt_tax = 0.00
+
+ total_receivable = order._total_receivable()
+
+ order.prev_outstanding_balance = total_receivable
+ order.total_outstanding_balance = total_receivable + amount_total + round_off_amount
+
+
order.update({
- 'amount_untaxed': order.pricelist_id.currency_id.round(amount_untaxed),
- 'amount_tax': order.pricelist_id.currency_id.round(amount_tax),
+ 'amount_untaxed': amt_untax,
+ 'amount_tax': amt_tax,
'amount_total': amount_total + round_off_amount,
'round_off_amount': round_off_amount,
- 'total_outstanding_balance': order.prev_outstanding_balance + amount_total + round_off_amount
+ 'discount': tot_discount,
+
})
def button_dummy(self):
- return self._amount_all()
+ return self._compute_amounts()
@api.depends('partner_id')
def _calculate_balance(self):
@@ -60,16 +79,15 @@ def _calculate_balance(self):
if (total_receivable - order.amount_total) < 0:
prev_outstanding_amt = 0
else:
- prev_outstanding_amt = total_receivable - order.amount_total
-
+ prev_outstanding_amt = total_receivable - order.amount_total
order.prev_outstanding_balance = prev_outstanding_amt
order.total_outstanding_balance = total_receivable
def _total_receivable(self):
receivable = 0.0
if self.partner_id:
- self._cr.execute("""select sum(amount_unpaid) from sale_order where
- amount_unpaid > 0 and partner_id = %s
+ self._cr.execute("""select sum(amount_residual) from account_move where
+ amount_residual > 0 and partner_id = %s
""", (self.partner_id.id,))
outstaning_value = self._cr.fetchall()
if outstaning_value[0][0] != None:
@@ -103,7 +121,7 @@ def _get_partner_details(self):
disc_acc_id = fields.Many2one('account.account', string="Discount Account Head")
round_off_amount = fields.Float(string="Round Off Amount")
prev_outstanding_balance = fields.Monetary(string="Previous Outstanding Balance",
- compute=_calculate_balance)
+ )
total_outstanding_balance = fields.Monetary(string="Total Outstanding Balance"
)
chargeable_amount = fields.Float(string="Chargeable Amount")
@@ -118,6 +136,7 @@ def _get_partner_details(self):
def onchange_order_line(self):
'''Calculate discount amount, when discount is entered in terms of %'''
amount_total = self.amount_untaxed + self.amount_tax
+ print("Level one test")
if self.discount_type == 'fixed':
self.discount_percentage = self.discount/amount_total * 100
elif self.discount_type == 'percentage':
@@ -126,6 +145,7 @@ def onchange_order_line(self):
@api.onchange('discount', 'discount_percentage', 'discount_type', 'chargeable_amount')
def onchange_discount(self):
amount_total = self.amount_untaxed + self.amount_tax
+ print("Level two test")
if self.chargeable_amount:
if self.discount_type == 'none' and self.chargeable_amount:
self.discount_type = 'fixed'
@@ -135,6 +155,7 @@ def onchange_discount(self):
if self.discount_type == 'none':
self.discount_percentage = 0
self.discount = 0
+ self.disc_acc_id = False
if self.discount:
self.discount_percentage = (self.discount / amount_total) * 100
if self.discount_percentage:
@@ -167,6 +188,12 @@ def _prepare_invoice(self):
a clean extension chain).
"""
self.ensure_one()
+ amount_total = self.amount_untaxed + self.amount_tax
+ if self.discount_percentage:
+ tot_discount = amount_total * self.discount_percentage / 100
+ else:
+ tot_discount = self.discount
+
invoice_vals = {
'name': self.client_order_ref or '',
'ref': self.client_order_ref or '',
@@ -186,7 +213,8 @@ def _prepare_invoice(self):
'discount_type': self.discount_type,
'discount_percentage': self.discount_percentage,
'disc_acc_id': self.disc_acc_id.id,
- 'discount': self.discount,
+ 'discount': tot_discount,
+ 'round_off_amount': self.round_off_amount,
}
return invoice_vals
diff --git a/bahmni_sale/models/sale_order_line.py b/bahmni_sale/models/sale_order_line.py
index 3815e3b..82dd027 100644
--- a/bahmni_sale/models/sale_order_line.py
+++ b/bahmni_sale/models/sale_order_line.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime
from odoo import models, fields, api
diff --git a/bahmni_sale/models/shop.py b/bahmni_sale/models/shop.py
index bbb406e..e637ef7 100644
--- a/bahmni_sale/models/shop.py
+++ b/bahmni_sale/models/shop.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
class SaleShop(models.Model):
@@ -10,5 +9,5 @@ class SaleShop(models.Model):
location_id = fields.Many2one('stock.location', 'Location')
payment_default_id = fields.Many2one('account.payment.term', 'Default Payment Term', required=True)
pricelist_id = fields.Many2one('product.pricelist', 'Pricelist')
- project_id = fields.Many2one('account.analytic.account', 'Analytic Account')#domain=[('parent_id', '!=', False)]
+ project_id = fields.Many2one('account.analytic.account', 'Analytic Account')
company_id = fields.Many2one('res.company', 'Company', required=False, default=lambda self: self.env['res.company']._company_default_get('sale.shop'))
diff --git a/bahmni_sale/models/village_master.py b/bahmni_sale/models/village_master.py
index cbd1ea3..380a57a 100644
--- a/bahmni_sale/models/village_master.py
+++ b/bahmni_sale/models/village_master.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from odoo import models, fields, api
diff --git a/bahmni_sale/views/bahmni_sale.xml b/bahmni_sale/views/bahmni_sale.xml
index 524a027..b7e69b4 100644
--- a/bahmni_sale/views/bahmni_sale.xml
+++ b/bahmni_sale/views/bahmni_sale.xml
@@ -1,17 +1,6 @@
-
-
-
-
diff --git a/bahmni_sale/views/sale_config_settings.xml b/bahmni_sale/views/sale_config_settings.xml
index f7a9862..427268d 100644
--- a/bahmni_sale/views/sale_config_settings.xml
+++ b/bahmni_sale/views/sale_config_settings.xml
@@ -22,7 +22,6 @@
-
diff --git a/bahmni_sale/views/sale_order_views.xml b/bahmni_sale/views/sale_order_views.xml
index 8a90669..9fb089d 100644
--- a/bahmni_sale/views/sale_order_views.xml
+++ b/bahmni_sale/views/sale_order_views.xml
@@ -38,14 +38,15 @@
+ attrs="{'readonly': [('discount_type', '=', 'percentage')],'invisible': [('discount_type', 'in', ('none'))]}"/>
+
+
-
-
+