[MERGE]: Merge with lp:~openerp-commiter/openobject-addons/osv-memory-wizards

bzr revid: rpa@tinyerp.com-20100311064633-67tfletn0zsw45yy
This commit is contained in:
rpa (Open ERP)
2010-03-11 12:16:33 +05:30
173 changed files with 5487 additions and 3878 deletions
+9
View File
@@ -42,9 +42,18 @@
'security/account_security.xml',
'security/ir.model.access.csv',
'account_menuitem.xml',
'wizard/account_invoice_refund_view.xml',
'wizard/account_period_close_view.xml',
'wizard/account_fiscalyear_close_state.xml',
'wizard/account_chart_view.xml',
'wizard/account_move_bank_reconcile_view.xml',
'wizard/account_move_line_reconcile_select_view.xml',
'wizard/account_move_journal_view.xml',
'account_wizard.xml',
'account_view.xml',
'account_end_fy.xml',
'account_invoice_view.xml',
'account_report.xml',
'partner_view.xml',
+10 -3
View File
@@ -191,14 +191,18 @@
<field name="amount_total"/>
<field name="state" select="2"/>
<field name="residual"/>
<group col="3" colspan="4">
<group col="7" colspan="4">
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-apply"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
<!-- Wizard Buttons: To Remove -->
<button name="%(wizard_invoice_pay)d" type="action" string="Pay Invoice" states="open,paid,proforma2" icon="STOCK_EXECUTE" />
<button name="%(action_account_invoice_refund)d" type="action" string="Credit Note" icon="STOCK_EXECUTE" />
</group>
</group>
</page>
<page string="Other Info">
<field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
@@ -281,13 +285,16 @@
<field name="amount_total"/>
<field name="state" select="2"/>
<field name="residual"/>
<group col="3" colspan="4" groups="base.group_user">
<group col="7" colspan="4" groups="base.group_user">
<button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="gtk-print"/>
<button name="invoice_open" states="draft,proforma2" string="Create" icon="gtk-execute"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid' icon="gtk-convert"/>
</group>
<!-- Wizard Buttons: To Remove -->
<button name="%(wizard_invoice_pay)d" type="action" string="Pay Invoice" states="open,paid,proforma2" icon="STOCK_EXECUTE" />
<button name="%(action_account_invoice_refund)d" type="action" string="Credit Note" icon="STOCK_EXECUTE" />
</group>
</group>
</page>
<page string="Other Info">
+14 -8
View File
@@ -81,6 +81,10 @@
<separator colspan="4" string="States"/>
<field name="state" select="1"/>
<button name="action_draft" states="done" string="Set to Draft" type="object" icon="gtk-convert"/>
<!-- Wizard Buttons: To Remove -->
<button name="%(action_account_period_close)d"
states="draft" string="Close Period" type="action"
icon="gtk-close" />
</form>
</field>
</record>
@@ -667,9 +671,8 @@
<field eval="'ir.actions.wizard,%d'%action_move_journal_line_form_select" name="value"/>
<field eval="True" name="object"/>
</record>
<wizard id="action_move_journal_line_form" menu="False" model="account.move.line" name="account.move.journal" string="Making Entries by Line"/>
<menuitem icon="STOCK_JUSTIFY_FILL" action="action_move_journal_line_form" id="menu_action_move_journal_line_form" parent="account.menu_finance_entries" type="wizard" sequence="5"/>
<!-- <wizard id="action_move_journal_line_form" menu="False" model="account.move.line" name="account.move.journal" string="Making Entries by Line"/>
<menuitem icon="STOCK_JUSTIFY_FILL" action="action_move_journal_line_form" id="menu_action_move_journal_line_form" parent="account.menu_finance_entries" type="wizard" sequence="5"/>-->
<!--
Entries lines
@@ -1007,9 +1010,9 @@
<menuitem action="action_move_line_search" id="menu_action_move_line_search" parent="account.next_id_29"/>
<menuitem id="menu_finance_charts" name="Charts" parent="account.menu_finance" sequence="4"/>
<wizard id="wizard_account_chart" menu="False" model="account.account" name="account.chart" string="Chart of Accounts"/>
<menuitem icon="STOCK_INDENT" action="wizard_account_chart" id="menu_action_account_tree2" parent="account.menu_finance_charts" type="wizard"/>
<!-- <wizard id="wizard_account_chart" menu="False" model="account.account" name="account.chart" string="Chart of Accounts"/>
<menuitem icon="STOCK_INDENT" action="wizard_account_chart" id="menu_action_account_tree2" parent="account.menu_finance_charts" type="wizard"/> -->
<record id="view_bank_statement_reconcile_form" model="ir.ui.view">
@@ -1079,8 +1082,11 @@
groups="group_account_user"/>
<menuitem action="action_bank_statement_reconciliation_form" id="menu_action_account_bank_reconcile_tree" parent="next_id_30"/>
<wizard id="action_account_bank_reconcile_tree" menu="False" model="account.move.line" name="account.move.bank.reconcile" string="Bank reconciliation"/>
<menuitem action="action_account_bank_reconcile_tree" id="menu_action_account_bank_reconcile_check_tree" parent="account.next_id_30" type="wizard"/>
<!--<wizard id="action_account_bank_reconcile_tree" menu="False" model="account.move.line" name="account.move.bank.reconcile" string="Bank reconciliation"/> -->
<menuitem action="action_account_bank_reconcile_tree"
id="menu_action_account_bank_reconcile_check_tree"
parent="account.next_id_30" />
<act_window
domain="[('account_id', '=', active_id)]"
+8 -10
View File
@@ -11,18 +11,18 @@
<wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice" groups="base.group_user"/>
<!-- close year, period, journal -->
<!-- close year, period, journal -->
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Generate Fiscal Year Opening Entries"/>
<menuitem
<!-- <menuitem
action="wizard_fiscalyear_close"
id="menu_wizard_fy_close"
parent="menu_account_end_year_treatments"
type="wizard"
sequence="1"/>
sequence="1"/>-->
<wizard id="wizard_fiscalyear_close_state" menu="False" model="account.fiscalyear" name="account.fiscalyear.close.state" string="Close a Fiscal Year"/>
<menuitem action="wizard_fiscalyear_close_state" id="menu_wizard_fy_close_state" parent="menu_account_end_year_treatments" type="wizard"/>
<wizard
id="wizard_open_closed_fiscalyear"
@@ -36,13 +36,12 @@
sequence="2"
parent="account.menu_account_end_year_treatments" type="wizard"/>
<wizard id="wizard_period_close" model="account.period" name="account.period.close" string="Close a Period"/>
<!-- <wizard id="wizard_period_close" model="account.period" name="account.period.close" string="Close a Period"/>-->
<!-- automatic reconcile -->
<wizard id="wizard_automatic_reconcile" menu="False" model="account.account" name="account.automatic.reconcile" string="Automatic reconciliation"/>
<menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/><menuitem action="wizard_automatic_reconcile" id="menu_automatic_reconcile" parent="next_id_20" type="wizard"/>
<!-- Import entry in statement -->
<!-- Import entry in statement -->
<wizard
string="Import invoices"
@@ -57,8 +56,7 @@
<wizard id="wizard_reconcile_unreconcile" model="account.move.reconcile" name="account.reconcile.unreconcile" string="Unreconcile Entries"/>
<wizard id="wizard_reconcile_select" menu="False" model="account.move.line" name="account.move.line.reconcile.select" string="Reconcile entries"/>
<menuitem action="wizard_reconcile_select" id="menu_reconcile_select" parent="account.next_id_20" type="wizard"/>
<!-- unreconcile -->
<wizard id="wizard_unreconcile" model="account.move.line" name="account.move.line.unreconcile" string="Unreconcile Entries"/>
+9 -9
View File
@@ -19,17 +19,14 @@
#
##############################################################################
# OLD Wizards
import wizard_automatic_reconcile
import wizard_reconcile_select
import wizard_unreconcile_select
import wizard_reconcile
import wizard_unreconcile
import wizard_refund
import wizard_pay_invoice
import wizard_journal
import wizard_journal_select
import wizard_bank_reconcile
import wizard_subscription_generate
import wizard_aged_trial_balance
@@ -38,9 +35,8 @@ import wizard_third_party_ledger
import wizard_account_balance_report
import wizard_partner_balance_report
import wizard_period_close
import wizard_fiscalyear_close
import wizard_fiscalyear_close_state
#import wizard_fiscalyear_close_state
import wizard_open_closed_fiscalyear
import wizard_vat
@@ -48,7 +44,6 @@ import wizard_compare_account_balance_report
import wizard_invoice_state
import wizard_account_duplicate
import wizard_account_chart
import wizard_move_line_select
import wizard_validate_account_move
@@ -62,7 +57,12 @@ import wizard_central_journal
import wizard_general_journal
import wizard_change_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import account_invoice_refund
import account_period_close
import account_fiscalyear_close_state
import account_chart
import account_move_bank_reconcile
import account_move_line_reconcile_select
import account_move_journal
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+87
View File
@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_chart(osv.osv_memory):
"""
For Chart of Accounrs
"""
def _get_defaults(self, cr, uid, context):
"""Return default Fiscalyear value"""
fiscalyear_obj = self.pool.get('account.fiscalyear')
fiscalyear = fiscalyear_obj.find(cr, uid)
return fiscalyear
def _account_chart_open_window(self, cr, uid, ids, context):
"""
Opens chart of Accounts
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of account chart’s IDs
@return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
"""
for data in self.read(cr, uid, ids):
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = str({'fiscalyear': data['fiscalyear'], \
'state': data['target_move']})
if data['fiscalyear']:
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']])[0]['code']
return result
_name = "account.chart"
_description = "chart"
_columns = {
'fiscalyear': fields.many2one('account.fiscalyear', \
'Fiscal year', required=True, \
help = 'Keep empty for all open fiscal years'),
'target_move': fields.selection([
('all', 'All Entries'),
('posted', 'All Posted Entries'),
], 'Target Moves', required = True),
}
_defaults = {
'fiscalyear': _get_defaults,
'target_move': lambda * a: 'all'
}
account_chart()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_chart" model="ir.ui.view">
<field name="name">account.chart.form</field>
<field name="model">account.chart</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account charts">
<group colspan="4" >
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<field name="target_move"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel" />
<button icon="gtk-open" string="Open Charts"
name="_account_chart_open_window" type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_chart" model="ir.actions.act_window">
<field name="name">Chart of Accounts</field>
<field name="res_model">account.chart</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_chart"/>
<field name="target">new</field>
</record>
<menuitem icon="STOCK_INDENT" action="action_account_chart"
id="menu_action_account_tree2"
parent="account.menu_finance_charts" />
</data>
</openerp>
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_fiscalyear_close_state(osv.osv_memory):
"""
Closes Account Fiscalyear
"""
_name = "account.fiscalyear.close.state"
_description = "Fiscalyear Close state"
_columns = {
'fy_id': fields.many2one('account.fiscalyear', \
'Fiscal Year to close', required=True),
'sure': fields.boolean('Check this box', required=False)
}
def _data_save(self, cr, uid, ids, context):
"""
This function close account fiscalyear
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Account fiscalyear close state’s IDs
"""
for data in self.read(cr, uid, ids):
if not data['sure']:
raise osv.except_osv(_('UserError'), _('Closing of states \
cancelled, please check the box !'))
fy_id = data['fy_id']
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period \
WHERE fiscalyear_id = %s)',
('done', fy_id))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('done', fy_id))
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s WHERE id = %s', ('done', fy_id))
return {}
account_fiscalyear_close_state()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_fiscalyear_close_state" model="ir.ui.view">
<field name="name">account.fiscalyear.close.state.form</field>
<field name="model">account.fiscalyear.close.state</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Close states of Fiscal year and periods">
<group colspan="4" >
<field name="fy_id" domain = "[('state','=','draft')]"/>
<separator string="Are you sure you want to close the fiscal year ?" colspan="4"/>
<field name="sure"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-close" string="Close states" name="_data_save" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_fiscalyear_close_state" model="ir.actions.act_window">
<field name="name">Close a Fiscal Year</field>
<field name="res_model">account.fiscalyear.close.state</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_fiscalyear_close_state"/>
<field name="target">new</field>
</record>
<menuitem action="action_account_fiscalyear_close_state"
id="menu_wizard_fy_close_state"
parent="menu_account_end_year_treatments" />
</data>
</openerp>
@@ -0,0 +1,214 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_invoice_refund(osv.osv_memory):
"""Refunds invoice."""
_name = "account.invoice.refund"
_description = "Invoice Refund"
_columns = {
'date': fields.date('Operation date', required=False),
'period': fields.many2one('account.period', 'Force period', required=False),
'description': fields.char('Description', size=150, required=True),
}
def _compute_refund(self, cr, uid, ids, mode, context):
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: the account invoice refund’s ID or list of IDs
"""
inv_obj = self.pool.get('account.invoice')
for form in self.read(cr, uid, ids):
reconcile_obj = self.pool.get('account.move.reconcile')
account_m_line_obj = self.pool.get('account.move.line')
created_inv = []
date = False
period = False
description = False
for inv in inv_obj.browse(cr, uid, context['active_ids']):
if inv.state in ['draft', 'proforma2', 'cancel']:
raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
if form['period'] :
period = form['period']
else:
period = inv.period_id and inv.period_id.id or False
if form['date'] :
date = form['date']
if not form['period'] :
cr.execute("select name from ir_model_fields \
where model = 'account.period' \
and name = 'company_id'")
result_query = cr.fetchone()
if result_query:
#in multi company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop \
and company_id = %s limit 1 """,
(form['date'], self.pool.get('res.users').browse(cr, uid, uid).company_id.id,))
else:
#in mono company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop \
limit 1 """, (form['date'],))
res = cr.fetchone()
if res:
period = res[0]
else:
date = inv.date_invoice
if form['description'] :
description = form['description']
else:
description = inv.name
if not period:
raise osv.except_osv(_('Data Insufficient !'), \
_('No Period found on Invoice!'))
refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description)
refund = inv_obj.browse(cr, uid, refund_id[0])
# we compute due date
#!!!due date = date inv date on formdate
inv_obj.write(cr, uid, [refund.id], {'date_due': date,
'check_total': inv.check_total})
# to make the taxes calculated
inv_obj.button_compute(cr, uid, refund_id)
created_inv.append(refund_id[0])
#if inv is paid we unreconcile
if mode in ('cancel', 'modify'):
movelines = inv.move_id.line_id
#we unreconcile the lines
to_reconcile_ids = {}
for line in movelines :
#if the account of the line is the as the one in the invoice
#we reconcile
if line.account_id.id == inv.account_id.id :
to_reconcile_ids[line.account_id.id] = [line.id]
if type(line.reconcile_id) != osv.orm.browse_null :
reconcile_obj.unlink(cr, uid, line.reconcile_id.id)
#we advance the workflow of the refund to open
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', \
refund.id, 'invoice_open', cr)
#we reload the browse record
refund = inv_obj.browse(cr, uid, refund_id[0])
#we match the line to reconcile
for tmpline in refund.move_id.line_id :
if tmpline.account_id.id == inv.account_id.id :
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
for account in to_reconcile_ids :
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
writeoff_period_id=period,
writeoff_journal_id=inv.journal_id.id,
writeoff_acc_id=inv.account_id.id
)
#we create a new invoice that is the copy of the original
if mode == 'modify' :
invoice = inv_obj.read(cr, uid, [inv.id],
['name', 'type', 'number', 'reference',
'comment', 'date_due', 'partner_id',
'address_contact_id', 'address_invoice_id',
'partner_insite', 'partner_contact',
'partner_ref', 'payment_term', 'account_id',
'currency_id', 'invoice_line', 'tax_line',
'journal_id', 'period_id'])
invoice = invoice[0]
del invoice['id']
invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'])
invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines)
tax_lines = self.pool.get('account.invoice.tax').read(
cr, uid, invoice['tax_line'])
tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines)
invoice.update({
'type': inv.type,
'date_invoice': date,
'state': 'draft',
'number': False,
'invoice_line': invoice_lines,
'tax_line': tax_lines,
'period_id': period,
'name': description
})
#take the id part of the tuple returned for many2one fields
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
inv_id = inv_obj.create(cr, uid, invoice, {})
# we compute due date
if inv.payment_term.id:
data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], inv.payment_term.id, date)
if 'value' in data and data['value']:
inv_obj.write(cr, uid, [inv_id], data['value'])
created_inv.append(inv_id)
#we get the view id
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
if inv.type == 'out_invoice':
xml_id = 'action_invoice_tree1'
elif inv.type == 'in_invoice':
xml_id = 'action_invoice_tree2'
elif type == 'out_refund':
xml_id = 'action_invoice_tree3'
else:
xml_id = 'action_invoice_tree4'
#we get the model
result = mod_obj._get_id(cr, uid, 'account', xml_id)
id = mod_obj.read(cr, uid, result, ['res_id'])['res_id']
# we read the act window
result = act_obj.read(cr, uid, id)
result['res_id'] = created_inv
return result
def _invoice_refund(self, cr, uid, ids, context):
return self._compute_refund(cr, uid, ids, 'refund', context)
def _invoice_cancel(self, cr, uid, ids, context):
return self._compute_refund(cr, uid, ids, 'cancel', context)
def _invoice_modify(self, cr, uid, ids, context):
return self._compute_refund(cr, uid, ids, 'modify', context)
account_invoice_refund()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_invoice_refund" model="ir.ui.view">
<field name="name">account.invoice.refund.form</field>
<field name="model">account.invoice.refund</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Credit Note">
<group colspan="4" >
<label string="Are you sure you want to refund this invoice ?" colspan="2"/>
<newline/>
<field name="date"/>
<field name="period"/>
<field name="description"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-redo" string="Refund Invoice" name="_invoice_refund" type="object"/>
<button icon="gtk-ok" string="Cancel Invoice" name="_invoice_cancel" type="object"/>
<button icon="gtk-undo" string="Modify Invoice" name="_invoice_modify" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_invoice_refund" model="ir.actions.act_window">
<field name="name">Credit Note</field>
<field name="res_model">account.invoice.refund</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_invoice_refund"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_move_bank_reconcile(osv.osv_memory):
"""
Bank Reconciliation
"""
_name = "account.move.bank.reconcile"
_description = "Move bank reconcile"
_columns = {
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
}
def _action_open_window(self, cr, uid, ids, context):
"""
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account move bank reconcile’s ID or list of IDs
@return: dictionary of Open account move line on given journal_id.
"""
for data in self.read(cr, uid, ids):
cr.execute('select default_credit_account_id \
from account_journal where id=%s', (data['journal_id'],))
account_id = cr.fetchone()[0]
if not account_id:
raise osv.except_osv(_('Error'), _('You have to define \
the bank account\nin the journal definition for reconciliation.'))
return {
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (data['journal_id'], account_id),
'name': _('Standard Encoding'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': False,
'context': "{'journal_id': %d}" % (data['journal_id'],),
'type': 'ir.actions.act_window'
}
account_move_bank_reconcile()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_bank_reconcile" model="ir.ui.view">
<field name="name">account.move.bank.reconcile.form</field>
<field name="model">account.move.bank.reconcile</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Bank reconciliation">
<group colspan="4" >
<field name="journal_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open for bank reconciliation" name="_action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_bank_reconcile_tree" model="ir.actions.act_window">
<field name="name">Bank reconciliation</field>
<field name="res_model">account.move.bank.reconcile</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_move_bank_reconcile"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,102 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_move_journal(osv.osv_memory):
def _get_period(self, cr, uid, context={}):
"""Return default account period value"""
ids = self.pool.get('account.period').find(cr, uid, context=context)
period_id = False
if len(ids):
period_id = ids[0]
return period_id
def _action_open_window(self, cr, uid, ids, context={}):
"""
This function Open action move line window on given period and Journal/Payment Mode
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account move journal’s ID or list of IDs
@return: dictionary of Open action move line window on given period and Journal/Payment Mode
"""
for data in self.read(cr, uid, ids, ['journal_id', 'period_id']):
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
view_res = cr.fetchone()
journal_id = data['journal_id']
period_id = data['period_id']
jp = self.pool.get('account.journal.period')
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), \
('period_id', '=', period_id)])
if not len(ids):
name = self.pool.get('account.journal').read(cr, uid, [journal_id])[0]['name']
state = self.pool.get('account.period').read(cr, uid, [period_id])[0]['state']
if state == 'done':
raise osv.except_osv(_('UserError'), _('This period is already closed !'))
company = self.pool.get('account.period').read(cr, uid, [period_id])[0]['company_id'][0]
jp.create(cr, uid, {'name': name, 'period_id': period_id, 'journal_id': journal_id, 'company_id': company})
ids = jp.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)])
jp = jp.browse(cr, uid, ids, context=context)[0]
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
return {
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (journal_id, period_id),
'name': name,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': view_res,
'context': "{'journal_id': %d, 'period_id': %d}" % (journal_id, period_id),
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
_name = "account.move.journal"
_description = "Move journal"
_columns = {
'journal_id': fields.many2one('account.journal', 'Journal/Payment Mode', required=True),
'period_id': fields.many2one('account.period', 'Period', required=True),
}
_defaults = {
'period_id': _get_period
}
account_move_journal()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_journal_form" model="ir.ui.view">
<field name="name">account.move.journal.form</field>
<field name="model">account.move.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Standard entries">
<group colspan="4" >
<field name="journal_id"/>
<newline/>
<field name="period_id" />
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open Journal" name="_action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_move_journal_line_form" model="ir.actions.act_window">
<field name="name">Making Entries by Line</field>
<field name="res_model">account.move.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_move_journal_form"/>
<field name="target">new</field>
</record>
<menuitem icon="STOCK_JUSTIFY_FILL"
action="action_account_move_journal_line_form"
id="menu_action_move_journal_line_form"
parent="account.menu_finance_entries" sequence="5" />
</data>
</openerp>
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_move_line_reconcile_select(osv.osv_memory):
_name = "account.move.line.reconcile.select"
_description = "Move line reconcile select"
_columns = {
'account_id': fields.many2one('account.account', 'Account', \
domain = [('reconcile', '=', 1)], required=True),
}
def _action_open_window(self, cr, uid, ids, context):
"""
This function Open account move line window for reconcile on given account id
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account move line reconcile select’s ID or list of IDs
@return: dictionary of Open account move line window for reconcile on given account id
"""
for data in self.read(cr, uid, ids):
return {
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'],
'name': _('Reconciliation'),
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
account_move_line_reconcile_select()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_move_line_reconcile_select" model="ir.ui.view">
<field name="name">account.move.line.reconcile.select.form</field>
<field name="model">account.move.line.reconcile.select</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Reconciliation">
<group colspan="4" >
<field name="account_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel" />
<button icon="gtk-open"
string="Open for reconciliation" name="_action_open_window"
type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_reconcile_select" model="ir.actions.act_window">
<field name="name">Reconcile entries</field>
<field name="res_model">account.move.line.reconcile.select</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_move_line_reconcile_select"/>
<field name="target">new</field>
</record>
<menuitem id="next_id_20" name="Reconciliation"
parent="menu_finance_periodical_processing" />
<menuitem action="action_account_reconcile_select"
id="menu_reconcile_select" parent="account.next_id_20" />
</data>
</openerp>
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class account_period_close(osv.osv_memory):
"""
close period
"""
_name = "account.period.close"
_description = "period close"
_columns = {
'sure': fields.boolean('Check this box', required=False),
}
def _data_save(self, cr, uid, ids, context):
"""
This function close period
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: account period close’s ID or list of IDs
"""
mode = 'done'
for form in self.read(cr, uid, ids):
if form['sure']:
for id in context['active_ids']:
cr.execute('update account_journal_period set state=%s \
where period_id=%s', (mode, id))
cr.execute('update account_period set state=%s \
where id=%s', (mode, id))
return {}
account_period_close()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_period_close" model="ir.ui.view">
<field name="name">account.period.close.form</field>
<field name="model">account.period.close</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Close Period">
<group colspan="4" >
<separator string="Are you sure ?" colspan="4"/>
<field name="sure"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-close" string="Close Period" name="_data_save" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_period_close" model="ir.actions.act_window">
<field name="name">Close a Period</field>
<field name="res_model">account.period.close</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_period_close"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,80 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
class wizard_account_chart(wizard.interface):
_account_chart_arch = '''<?xml version="1.0"?>
<form string="Account charts">
<field name="fiscalyear"/>
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<field name="target_move"/>
</form>'''
_account_chart_fields = {
'fiscalyear': {
'string': 'Fiscal year',
'type': 'many2one',
'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal years',
},
'target_move': {
'string': 'Target Moves',
'type': 'selection',
'selection': [('all','All Entries'),('posted','All Posted Entries')],
'required': True,
'default': lambda *a:"all",
},
}
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
return data['form']
def _account_chart_open_window(self, cr, uid, data, context):
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = str({'fiscalyear': data['form']['fiscalyear'],'state':data['form']['target_move']})
if data['form']['fiscalyear']:
result['name']+=':'+pooler.get_pool(cr.dbname).get('account.fiscalyear').read(cr,uid,[data['form']['fiscalyear']])[0]['code']
return result
states = {
'init': {
'actions': [_get_defaults],
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel'), ('open', 'Open Charts')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
}
}
wizard_account_chart('account.chart')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,67 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
from tools.translate import _
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="journal_id"/>
</form>''' % ('Bank reconciliation',)
_journal_fields = {
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
cr.execute('select default_credit_account_id from account_journal where id=%s', (form['journal_id'],))
account_id = cr.fetchone()[0]
if not account_id:
raise wizard.except_wizard(_('Error'), _('You have to define the bank account\nin the journal definition for reconciliation.'))
return {
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id),
'name': _('Standard Encoding'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': False,
'context': "{'journal_id':%d}" % (form['journal_id'],),
'type': 'ir.actions.act_window'
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for bank reconciliation')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.bank.reconcile')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,71 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import osv
import pooler
from tools.translate import _
_transaction_form = '''<?xml version="1.0"?>
<form string=" Close states of Fiscal year and periods">
<field name="fy_id"/>
<separator string="Are you sure you want to close the fiscal year ?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_save(self, cr, uid, data, context):
if not data['form']['sure']:
raise wizard.except_wizard(_('UserError'), _('Closing of states cancelled, please check the box !'))
pool = pooler.get_pool(cr.dbname)
fy_id = data['form']['fy_id']
cr.execute('UPDATE account_journal_period ' \
'SET state = %s ' \
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)',
('done',fy_id))
cr.execute('UPDATE account_period SET state = %s ' \
'WHERE fiscalyear_id = %s', ('done',fy_id))
cr.execute('UPDATE account_fiscalyear ' \
'SET state = %s WHERE id = %s', ('done', fy_id))
return {}
class wiz_journal_close_state(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close states')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close_state('account.fiscalyear.close.state')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-99
View File
@@ -1,99 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
from osv import osv
import pooler
from tools.translate import _
_journal_form = '''<?xml version="1.0"?>
<form string="Standard entries">
<field name="journal_id"/>
<newline/>
<field name="period_id"/>
</form>'''
def _period_get(self, cr, uid, datas, ctx={}):
try:
pool = pooler.get_pool(cr.dbname)
ids = pool.get('account.period').find(cr, uid, context=ctx)
return {'period_id': ids[0]}
except:
return {}
_journal_fields = {
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
'period_id': {
'string':'Period',
'type':'many2one',
'relation':'account.period',
'required':True,
}
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
view_res = cr.fetchone()
jp = pooler.get_pool(cr.dbname).get('account.journal.period')
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
if not len(ids):
name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state']
if state == 'done':
raise wizard.except_wizard(_('UserError'), _('This period is already closed !'))
company = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['company_id'][0]
jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id'], 'company_id':company})
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
jp = jp.browse(cr, uid, ids, context=context)[0]
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
return {
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (form['journal_id'],form['period_id']),
'name': name,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': view_res,
'context': "{'journal_id':%d, 'period_id':%d}" % (form['journal_id'],form['period_id']),
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [_period_get],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open Journal')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.journal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,57 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Period">
<separator string="Are you sure ?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_save(self, cr, uid, data, context):
mode = 'done'
if data['form']['sure']:
for id in data['ids']:
cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id))
cr.execute('update account_period set state=%s where id=%s', (mode, id))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Period')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close('account.period.close')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+30 -30
View File
@@ -19,13 +19,13 @@
#
##############################################################################
import wizard
import netsvc
import time
import osv
import pooler
from datetime import datetime
from tools.translate import _
import netsvc
import osv
import pooler
import time
import wizard
_transaction_form = '''<?xml version="1.0"?>
<form string="Reconciliation">
@@ -39,10 +39,10 @@ _transaction_form = '''<?xml version="1.0"?>
</form>'''
_transaction_fields = {
'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
}
def _trans_rec_get(self, cr, uid, data, context=None):
@@ -83,12 +83,12 @@ def _trans_rec_reconcile(self, cr, uid, data, context=None):
journal_id = form.get('journal_id', False)
context['comment'] = form.get('comment', False)
context['analytic_id'] = form.get('analytic_id', False)
account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
period_id, journal_id, context=context)
return {}
def _partial_check(self, cr, uid, data, context):
if _trans_rec_get(self,cr,uid, data, context)['writeoff'] == 0:
if _trans_rec_get(self, cr, uid, data, context)['writeoff'] == 0:
return 'init_full'
return 'init_partial'
@@ -104,11 +104,11 @@ _transaction_add_form = '''<?xml version="1.0"?>
</form>'''
_transaction_add_fields = {
'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
'date_p': {'string':'Date','type':'date'},
'comment': {'string':'Comment','type':'char', 'size': 64, 'required':True},
'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
'date_p': {'string':'Date', 'type':'date'},
'comment': {'string':'Comment', 'type':'char', 'size': 64, 'required':True},
'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
}
def _trans_rec_addendum(self, cr, uid, data, context={}):
@@ -119,27 +119,27 @@ def _trans_rec_addendum(self, cr, uid, data, context={}):
class wiz_reconcile(wizard.interface):
states = {
'init': {
'actions': [],
'actions': [],
'result': {'type': 'choice', 'next_state': _partial_check}
},
},
'init_full': {
'actions': [_trans_rec_get],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
},
'actions': [_trans_rec_get],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end', 'Cancel'), ('reconcile', 'Reconcile')]}
},
'init_partial': {
'actions': [_trans_rec_get],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('addendum','Reconcile With Write-Off'),('partial','Partial Reconcile')]}
},
'actions': [_trans_rec_get],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end', 'Cancel'), ('addendum', 'Reconcile With Write-Off'), ('partial', 'Partial Reconcile')]}
},
'addendum': {
'actions': [_trans_rec_addendum],
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
},
'actions': [_trans_rec_addendum],
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end', 'Cancel'), ('reconcile', 'Reconcile')]}
},
'reconcile': {
'actions': [_trans_rec_reconcile],
'actions': [_trans_rec_reconcile],
'result': {'type': 'state', 'state':'end'}
},
},
'partial': {
'actions': [_trans_rec_reconcile_partial],
'actions': [_trans_rec_reconcile_partial],
'result': {'type': 'state', 'state':'end'}
}
}
@@ -1,61 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
from tools.translate import _
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="account_id"/>
</form>''' % ('Reconciliation',)
_journal_fields = {
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account','domain': [('reconcile','=',1)], 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
return {
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['form']['account_id'],
'name': _('Reconciliation'),
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
class wiz_rec_select(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for reconciliation')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_rec_select('account.move.line.reconcile.select')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-226
View File
@@ -1,226 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import osv
import netsvc
import time
from tools.translate import _
sur_form = '''<?xml version="1.0"?>
<form string="Credit Note">
<label string="Are you sure you want to refund this invoice ?" colspan="2"/>
<newline />
<field name="date" />
<field name="period" />
<field name="description" width="150" />
</form>'''
sur_fields = {
'date': {'string':'Operation date','type':'date', 'required':'False'},
'period':{'string': 'Force period', 'type': 'many2one',
'relation': 'account.period', 'required': False},
'description':{'string':'Description', 'type':'char', 'required':'True'},
}
class wiz_refund(wizard.interface):
def _invoice_refund(self, cr, uid, data, context):
return self._compute_refund(cr, uid, data, 'refund', context)
def _invoice_cancel(self, cr, uid, data, context):
return self._compute_refund(cr, uid, data, 'cancel', context)
def _invoice_modify(self, cr, uid, data, context):
return self._compute_refund(cr, uid, data, 'modify', context)
def _compute_refund(self, cr, uid, data, mode, context):
form = data['form']
pool = pooler.get_pool(cr.dbname)
reconcile_obj = pool.get('account.move.reconcile')
account_m_line_obj = pool.get('account.move.line')
created_inv = []
date = False
period = False
description = False
for inv in pool.get('account.invoice').browse(cr, uid, data['ids']):
if inv.state in ['draft', 'proforma2', 'cancel']:
raise wizard.except_wizard(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
if form['period'] :
period = form['period']
else:
period = inv.period_id and inv.period_id.id or False
if form['date'] :
date = form['date']
if not form['period'] :
cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'")
result_query = cr.fetchone()
if result_query:
#in multi company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop and company_id = %s limit 1 """,
(form['date'],pool.get('res.users').browse(cr,uid,uid).company_id.id,))
else:
#in mono company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop limit 1 """,
(form['date'],))
res = cr.fetchone()
if res:
period = res[0]
else:
date = inv.date_invoice
if form['description'] :
description = form['description']
else:
description = inv.name
if not period:
raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
# we compute due date
#!!!due date = date inv date on formdate
pool.get('account.invoice').write(cr, uid, [refund.id],{'date_due':date,'check_total':inv.check_total})
# to make the taxes calculated
pool.get('account.invoice').button_compute(cr, uid, refund_id)
created_inv.append(refund_id[0])
#if inv is paid we unreconcile
if mode in ('cancel','modify'):
movelines = inv.move_id.line_id
#we unreconcile the lines
to_reconcile_ids = {}
for line in movelines :
#if the account of the line is the as the one in the invoice
#we reconcile
if line.account_id.id == inv.account_id.id :
to_reconcile_ids[line.account_id.id] =[line.id]
if type(line.reconcile_id) != osv.orm.browse_null :
reconcile_obj.unlink(cr,uid, line.reconcile_id.id)
#we advance the workflow of the refund to open
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', refund.id, 'invoice_open', cr)
#we reload the browse record
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
#we match the line to reconcile
for tmpline in refund.move_id.line_id :
if tmpline.account_id.id == inv.account_id.id :
to_reconcile_ids[tmpline.account_id.id].append(tmpline.id)
for account in to_reconcile_ids :
account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account],
writeoff_period_id=period,
writeoff_journal_id=inv.journal_id.id,
writeoff_acc_id=inv.account_id.id
)
#we create a new invoice that is the copy of the original
if mode == 'modify' :
invoice = pool.get('account.invoice').read(cr, uid, [inv.id],
['name', 'type', 'number', 'reference',
'comment', 'date_due', 'partner_id', 'address_contact_id',
'address_invoice_id', 'partner_insite','partner_contact',
'partner_ref', 'payment_term', 'account_id', 'currency_id',
'invoice_line', 'tax_line', 'journal_id','period_id'
]
)
invoice = invoice[0]
del invoice['id']
invoice_lines = pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'])
invoice_lines = pool.get('account.invoice')._refund_cleanup_lines(cr, uid, invoice_lines)
tax_lines = pool.get('account.invoice.tax').read(
cr, uid, invoice['tax_line'])
tax_lines = pool.get('account.invoice')._refund_cleanup_lines(cr, uid, tax_lines)
invoice.update({
'type': inv.type,
'date_invoice': date,
'state': 'draft',
'number': False,
'invoice_line': invoice_lines,
'tax_line': tax_lines,
'period_id': period,
'name':description
})
#take the id part of the tuple returned for many2one fields
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
inv_id = pool.get('account.invoice').create(cr, uid, invoice,{})
# we compute due date
if inv.payment_term.id:
data = pool.get('account.invoice').onchange_payment_term_date_invoice(cr, uid, [inv_id],inv.payment_term.id,date)
if 'value' in data and data['value']:
pool.get('account.invoice').write(cr, uid, [inv_id],data['value'])
created_inv.append(inv_id)
#we get the view id
mod_obj = pool.get('ir.model.data')
act_obj = pool.get('ir.actions.act_window')
if inv.type == 'out_invoice':
xml_id = 'action_invoice_tree5'
elif inv.type == 'in_invoice':
xml_id = 'action_invoice_tree8'
elif type == 'out_refund':
xml_id = 'action_invoice_tree10'
else:
xml_id = 'action_invoice_tree12'
#we get the model
result = mod_obj._get_id(cr, uid, 'account', xml_id)
id = mod_obj.read(cr, uid, result, ['res_id'])['res_id']
# we read the act window
result = act_obj.read(cr, uid, id)
result['res_id'] = created_inv
return result
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':sur_form, 'fields':sur_fields, 'state':[('end','Cancel'),('refund','Refund Invoice'),('cancel_invoice','Cancel Invoice'),('modify_invoice','Modify Invoice')]}
},
'refund': {
'actions': [],
'result': {'type':'action', 'action':_invoice_refund, 'state':'end'},
},
'cancel_invoice': {
'actions': [],
'result': {'type':'action', 'action':_invoice_cancel, 'state':'end'},
},
'modify_invoice': {
'actions': [],
'result': {'type':'action', 'action':_invoice_modify, 'state':'end'},
},
}
wiz_refund('account.invoice.refund')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -1
View File
@@ -47,7 +47,7 @@ class wiz_state_open(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','No','gtk-no'),('yes','Yes','gtk-yes')]}
'result': {'type':'form', 'arch':form, 'fields': fields, 'state':[('end','No','gtk-no'),('yes','Yes','gtk-yes')]}
},
'yes': {
'actions': [_change_inv_state],
+2 -1
View File
@@ -43,7 +43,8 @@
"voucher_sequence.xml",
"account_report.xml",
"voucher_view.xml",
"voucher_wizard.xml",
"wizard/account_voucher_open_view.xml",
#"voucher_wizard.xml",
"account_view.xml",
],
'certificate': '0037580727101',
+2 -1
View File
@@ -19,4 +19,5 @@
#
##############################################################################
import open_voucher
import account_voucher_open
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import RelativeDateTime
from osv import fields, osv
from tools import config
import ir
import mx.DateTime
import netsvc
import pooler
import time
class account_voucher_open(osv.osv_memory):
"""
Open Account Voucher
"""
_name ="account.voucher.open"
_description ="Open Voucher"
_columns ={
'type':fields.selection([('pay_voucher','Cash Payment Voucher'),('bank_pay_voucher','Bank Payment Voucher'),('rec_voucher','Cash Receipt Voucher'),('bank_rec_voucher','Bank Receipt Voucher'),('cont_voucher','Contra Voucher'),( 'journal_sale_vou','Journal Sale Voucher'),('journal_pur_voucher','Journal Purchase Voucher')], 'Voucher Type', required=True),
'state':fields.selection([('draft','Draft'),
('proforma','Pro-forma'),
('posted','Posted'),
('cancel','Cancel')], 'State', required=True),
'period_ids':fields.many2many('account.period', 'account_period_rel', 'voucher_id', 'period_id', 'Periods')
}
def _action_open_window(self, cr, uid, ids, context):
"""
Open account voucher form.
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param id: List of account voucher open’s IDs.
@param return:dictionary of account voucher on given state ,type and account period id.
"""
for form in self.read(cr, uid, ids):
periods = []
if not form['period_ids']:
period = self.pool.get('account.period')
year = self.pool.get('account.fiscalyear')
year = year.find(cr, uid)
periods = period.search(cr, uid, [('fiscalyear_id','=',year)])
else:
periods = form['period_ids']
return {
'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
'name': "%s - %s" % (form['type'],form['state']),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.voucher',
'view_id': False,
'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
'type': 'ir.actions.act_window'
}
account_voucher_open()
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_voucher_open_form" model="ir.ui.view">
<field name="name">account.voucher.open.form</field>
<field name="model">account.voucher.open</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Open Vouchers">
<group colspan="4" >
<field name="type"/>
<field name="state"/>
<field name="period_ids" colspan="4"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open Voucher Entries" name="_action_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_account_voucher_open" model="ir.actions.act_window">
<field name="name">Open a Voucher Entry</field>
<field name="res_model">account.voucher.open</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_voucher_open_form"/>
<field name="target">new</field>
</record>
<menuitem
action="action_account_voucher_open"
id="menu_wizard_account_voucher_open"
name="Open Vouchers"
sequence="0"
parent="menu_action_voucher_list"/>
</data>
</openerp>
@@ -1,104 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
from tools.translate import _
import pooler
_voucher_form = '''<?xml version="1.0"?>
<form string="Open Vouchers">
<field name="type"/>
<field name="state"/>
<field name="period_ids" colspan="4"/>
</form>'''
_types = {
'pay_voucher':'Cash Payment Voucher',
'bank_pay_voucher':'Bank Payment Voucher',
'rec_voucher':'Cash Receipt Voucher',
'bank_rec_voucher':'Bank Receipt Voucher',
'cont_voucher':'Contra Voucher',
'journal_sale_vou':'Journal Sale Voucher',
'journal_pur_voucher':'Journal Purchase Voucher'
}
_states = {
'draft':'Draft',
'proforma':'Pro-forma',
'posted':'Posted',
'cancel':'Cancel'
}
_voucher_fields = {
'type': {'string':'Voucher Type', 'type':'selection', 'selection':[
('pay_voucher','Cash Payment Voucher'),
('bank_pay_voucher','Bank Payment Voucher'),
('rec_voucher','Cash Receipt Voucher'),
('bank_rec_voucher','Bank Receipt Voucher'),
('cont_voucher','Contra Voucher'),
('journal_sale_vou','Journal Sale Voucher'),
('journal_pur_voucher','Journal Purchase Voucher')], 'required':True},
'state': {'string':'State', 'type':'selection', 'selection':[
('draft','Draft'),
('proforma','Pro-forma'),
('posted','Posted'),
('cancel','Cancel')], 'required':True},
'period_ids': {'string':'Periods', 'type':'many2many', 'relation':'account.period'},
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
periods = []
if not form['period_ids'][0][2]:
pool = pooler.get_pool(cr.dbname)
period = pool.get('account.period')
year = pool.get('account.fiscalyear')
year = year.find(cr, uid)
periods = period.search(cr, uid, [('fiscalyear_id','=',year)])
else:
periods = form['period_ids'][0][2]
return {
'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
'name': "%s - %s" % (_types[form['type']], _states[form['state']]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.voucher',
'view_id': False,
'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
'type': 'ir.actions.act_window'
}
class OpenVoucherEntries(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_voucher_form, 'fields':_voucher_fields, 'state':[('end','Cancel'),('open','Open Voucher Entries')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
OpenVoucherEntries('account.voucher.open')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+10
View File
@@ -34,6 +34,16 @@
'init_xml': ['auction_sequence.xml'],
'update_xml': [
'security/ir.model.access.csv',
'wizard/auction_lots_able_view.xml',
'wizard/auction_lots_enable_view.xml',
'wizard/auction_lots_make_invoice_buyer_view.xml',
'wizard/auction_lots_make_invoice_view.xml',
'wizard/auction_taken_view.xml',
'wizard/auction_lots_auction_move_view.xml',
'wizard/auction_pay_buy_view.xml',
'wizard/auction_payer_sel_view.xml',
'wizard/auction_lots_sms_send_view.xml',
'auction_view.xml',
'auction_report.xml',
'auction_wizard.xml'
+5 -3
View File
@@ -478,13 +478,15 @@ class auction_lots(osv.osv):
result = [ (r['id'], str(r['obj_num'])+' - '+r['name']) for r in self.read(cr, user, ids, ['name','obj_num'])]
return result
def name_search(self, cr, user, name, args=[], operator='ilike', context={}):
def name_search(self, cr, user, name, args=None, operator='ilike', context={}):
if not args:
args = []
try:
ids = self.search(cr, user, [('obj_num','=',int(name))]+ args)
ids = self.search(cr, user, [('obj_num','=',int(name))] + args)
except:
ids = []
if not ids:
ids = self.search(cr, user, [('name',operator,name)]+ args)
ids = self.search(cr, user, [('name',operator,name)] + args)
return self.name_get(cr, user, ids)
def _sum_taxes_by_type_and_id(self, taxes):
+4 -5
View File
@@ -3,7 +3,8 @@
<data>
<menuitem name="Auction Management" id="auction_menu_root" icon="terp-purchase"/>
<menuitem name="Configuration" parent="auction_menu_root" id="auction_config_menu" sequence="7"/>
<menuitem name="Tools Bar Codes" id="auction_outils_menu" parent="auction_menu_root" sequence="5" />
<menuitem name="Deliveries Management" action="action_auction_taken" id="menu_wizard_emporte" parent="auction_outils_menu"/>
=======================================================
Auction Management/Configuration/artist
=======================================================
@@ -203,6 +204,7 @@
<field name="lot_est2"/>
<field name="product_id"/>
<field name="state" readonly="1"/>
</form>
</field>
</record>
@@ -277,7 +279,7 @@
<separator string="Description" colspan="4"/>
<field name="obj_desc" colspan="4" nolabel="1" select="2"/>
<field name="state" colspan="1" select="2"/>
<group col="4" colspan="2">
<group col="8" colspan="2">
<button name="button_bought" string="Sold" states="draft" type="object" icon="gtk-jump-to"/>
<button name="button_not_bought" string="Not sold" states="draft" type="object" icon="gtk-undo"/>
<button name="button_taken_away" string="Taken away" states="sold" type="object" icon="gtk-goto-last"/>
@@ -330,7 +332,6 @@
<field name="date"/>
</tree>
</field>
</page>
<page string="Bids">
<field name="bid_lines" colspan="4" nolabel="1" editable="top">
@@ -340,9 +341,7 @@
<field name="call"/>
</tree>
</field>
</page>
</notebook>
</form>
</field>
+3 -85
View File
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<openerp>
<data>
<!--<delete model="ir.actions.wizard" search="[('wiz_name','like','auction.lots.')]"/>-->
<!-- Following wizard is remaining to implement in osv_memory-->
<!--
<wizard string="Send to website"
model="auction.lots"
name="auction.lots.send.aie"
@@ -20,45 +20,6 @@
multi="1"
id="wizard_map_user"/>
<wizard string="Change Auction Date"
model="auction.lots"
name="auction.lots.auction_move"
multi="1"
id="wizard_change_auction"/>
<!--wizard string="Pay objects of the seller"
model="auction.lots"
name="auction.pay.sel"
id="wizard_lots_pay"/-->
<wizard string="Pay objects of the buyer"
model="auction.lots"
name="auction.pay.buy"
id="wizard_pay"/>
<wizard
string="Gestion emporte"
model="auction.dates"
name="auction.taken"
multi="1"
id="wizard_emporte"/>
<menuitem name="Tools Bar Codes"
id="auction_outils_menu"
parent="auction_menu_root" sequence="5"
/>
<menuitem name="Deliveries Management"
action="wizard_emporte"
type="wizard"
id="menu_wizard_emporte"
parent="auction_outils_menu"
/>
<!--wizard string="Cancel payment"
model="auction.lots"
name="auction.lots.cancel"
multi="1"
id="wizard_cancel_pay"/-->
<wizard string="Numerotation (per lot)"
model="auction.lots"
@@ -72,56 +33,13 @@
multi="1"
id="wizard_numerotate_automatic"/>
<wizard string="SMS Send"
model="auction.lots"
name="auction.lots.sms_send"
multi="1"
id="wizard_sms"/>
<!--wizard string="Invoice"
model="auction.lots"
name="auction.lots.invoice"
multi="1"
id="wizard_invoicing"/-->
<wizard string="Invoice Seller objects"
model="auction.lots"
name="auction.lots.make_invoice"
multi="1"
id="wizard_invoice"/>
<wizard string="Invoice Buyer objects"
model="auction.lots"
name="auction.lots.make_invoice_buyer"
id="wizard_invoice_buyer1"/>
<wizard string="Unmark as taken away"
model="auction.lots"
name="auction.lots.enable"
multi="1"
id="auction_wizard_enable_taken"/>
<wizard string="Mark as taken away"
model="auction.lots"
name="auction.lots.able"
multi="1"
id="auction_wizard_able_taken"/>
<wizard
id="auction_catalog_flagy"
string="Auction Catalog Flagey"
model="auction.dates"
name="auction.catalog.flagey"
keyword="client_print_multi"/>
<wizard string="Mark as paid for seller"
model="auction.lots"
name="auction.payer.sel"
multi="1"
id="auction_wizard_payer_sel"/>
-->
</data>
</openerp>
+22 -19
View File
@@ -19,24 +19,27 @@
#
##############################################################################
import wizard_aie_send
import wizard_aie_send_result
import wizard_lots_buyer_map
import wizard_lots_cancel
import wizard_lots_invoice
import wizard_lots_numerotate
import wizard_lots_pay
import wizard_pay
import wizard_lots_sms
import wizard_lot_date_move
import wizard_auction_journal
import wizard_auction_invoice_buyer
import wizard_transfer_unsold_object
import auction_wizard_enable_taken
import auction_wizard_able_taken
import auction_catalog_flagey
#import wizard_lots_barcode
import wizard_emporte
import wizard_payer
#import wizard_aie_send
#import wizard_aie_send_result
#import wizard_lots_buyer_map
#import wizard_lots_cancel
#import wizard_lots_invoice
#import wizard_lots_numerotate
#import wizard_lots_pay
#import wizard_pay
#import wizard_lot_date_move
#import wizard_transfer_unsold_object
#import auction_catalog_flagey
import auction_lots_able
import auction_lots_enable
import auction_lots_make_invoice_buyer
import auction_lots_make_invoice
import auction_taken
import auction_lots_auction_move
import auction_pay_buy
import auction_payer_sel
import auction_lots_sms_send
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_able(osv.osv_memory):
_name = "auction.lots.able"
_description = "Lots able"
def _confirm_able(self, cr, uid, ids, context={}):
"""
This function Update auction lots object and set taken away field true.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of auction lots able’s IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'ach_emp':True})
return {}
auction_lots_able()
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_able" model="ir.ui.view">
<field name="name">auction.lots.able.form</field>
<field name="model">auction.lots.able</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Confirm">
<group colspan="4" >
<separator string="Confirmation set taken away" colspan="4"/>
<newline/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-goto-last" string="Able Taken away" name="_confirm_able" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_able" model="ir.actions.act_window">
<field name="name">Mark as taken away</field>
<field name="res_model">auction.lots.able</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_able"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_able_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Mark as taken away</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_able'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_auction_move(osv.osv_memory):
_name = "auction.lots.auction.move"
_description = "Auction move "
_columns= {
'auction_id':fields.many2one('auction.dates', 'Auction Date', required=True),
}
def _top(self, cr, uid, ids, context={}):
refs = self.pool.get('auction.lots')
rec_ids = refs.browse(cr, uid, context['active_ids'])
for rec in rec_ids:
if not rec.auction_id:
raise osv.except_osv('Error !', 'You can not move a lot that has no auction date')
return {}
def _auction_move_set(self, cr, uid, ids, context={}):
"""
This Function update auction date on auction lots to given auction date.
erase the auction lots's object adjudication price and its buyer and change state to draft.
create new entry in auction lot history.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of auction lots auction move’s IDs.
"""
for datas in self.read(cr, uid, ids):
if not (datas['auction_id'] and len(context['active_ids'])) :
return {}
refs = self.pool.get('auction.lots')
rec_ids = refs.browse(cr, uid, context['active_ids'])
line_ids = self.pool.get('auction.bid_line').search(cr, uid, [('lot_id', 'in', context['active_ids'])])
# pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
for rec in rec_ids:
new_id = self.pool.get('auction.lot.history').create(cr, uid, {
'auction_id': rec.auction_id.id,
'lot_id': rec.id,
'price': rec.obj_ret
})
up_auction = self.pool.get('auction.lots').write(cr, uid, [rec.id], {
'auction_id':datas['auction_id'],
'obj_ret': None,
'obj_price': None,
'ach_login': None,
'ach_uid': None,
'ach_inv_id': None,
'sel_inv_id': None,
'obj_num': None,
'state': 'draft'})
return {}
auction_lots_auction_move()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_auction_move" model="ir.ui.view">
<field name="name">auction.lots.auction.move.form</field>
<field name="model">auction.lots.auction.move</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Change Auction Date">
<group colspan="4" >
<label string="Warning, this will erase the object adjudication price and its buyer !" colspan="2"/>
<newline/>
<field name="auction_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-redo" string="Move to Auction date" name="_auction_move_set" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_auction_move" model="ir.actions.act_window">
<field name="name">Change Auction Date</field>
<field name="res_model">auction.lots.auction.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_auction_move"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_auction_move_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Change Auction Date</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_auction_move'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_enable(osv.osv_memory):
_name = "auction.lots.enable"
_description = "Lots Enable"
_columns= {
'confirm_en':fields.integer('Catalog Number')
}
def _confirm_enable(self, cr, uid, ids, context={}):
"""
This function Update auction lots object and set taken away field False.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of auction lots enable’s IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_id'], {'ach_emp':False})
return {}
auction_lots_enable()
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_enable" model="ir.ui.view">
<field name="name">auction.lots.enable.form</field>
<field name="model">auction.lots.enable</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Confirm">
<group colspan="4" >
<separator string="Confirmation enable taken away" colspan="4"/>
<newline/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-goto-last" string="Enable Taken away" name="_confirm_enable" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_enable" model="ir.actions.act_window">
<field name="name">Unmark as taken away</field>
<field name="res_model">auction.lots.enable</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_enable"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_enable_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Unmark as taken away</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_enable'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_make_invoice(osv.osv_memory):
def _value_amount(self, cr, uid, context={}):
"""
For Amount default value
@return:default auction lots amount value in amount fields.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
amount_total=0.0
for lot in lots:
amount_total+=lot.seller_price
return amount_total
def _value_object(self, cr, uid, context={}):
"""
For object default value.
@return:length of id in Object field.
"""
object = len(context['active_ids'])
return object
def _makeInvoices(self, cr, uid, ids, context):
"""
seller invoice :Create an invoice.
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: List of Auction lots make invoice’s IDs
@return: dictionary of account invoice form.
"""
for data in self.read(cr, uid, ids):
order_obj = self.pool.get('auction.lots')
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
newinv = []
ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context)
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Seller invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
_name = "auction.lots.make.invoice"
_description = "Make invoice"
_columns= {
'amount': fields.float('Invoiced Amount', required =True, readonly=True),
'objects':fields.integer('# of objects', required =True, readonly=True),
'number':fields.char('Invoice Number', size=64),
}
_defaults={
'amount':_value_amount,
'objects':_value_object,
'number':lambda *a: False,
}
auction_lots_make_invoice()
@@ -0,0 +1,109 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_make_invoice_buyer(osv.osv_memory):
def _value_amount(self, cr, uid, context={}):
"""
For Amount default value
@return:default auction lots amount value in amount fields.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
amount_total=0.0
for lot in lots:
amount_total+=lot.buyer_price
return amount_total
def _value_object(self, cr, uid, context={}):
"""
For object default value.
@return:length of id in Object field.
"""
object = len(context['active_ids'])
return object
def _value_buyer_id(self, cr, uid, context={}):
"""
For default buyer id value
@return:auction lots buyer id in buyer id field.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
for lot in lots:
buyer=lot and lot.ach_uid.id or False
return buyer
def _makeInvoices(self, cr, uid, ids, context):
"""
Create an invoice for selected lots (IDS) to BUYER_ID .
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: List of Auction lots make invoice buyer’s IDs
@return: dictionary of account invoice form.
"""
newinv = []
for data in self.read(cr, uid, ids):
order_obj = self.pool.get('auction.lots')
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
lots = order_obj.browse(cr, uid, context['active_ids'])
invoice_number = data['number']
for lot in lots:
up_auction = self.pool.get('auction.lots').write(cr, uid, [lot.id], {'ach_uid':data['buyer_id']})
ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number'])
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Buyer invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'in_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
_name = "auction.lots.make.invoice.buyer"
_description = "Make invoice buyer "
_columns= {
'amount': fields.float('Invoiced Amount', required =True, readonly=True),
'objects':fields.integer('# of objects', required =True, readonly=True),
'number':fields.char('Invoice Number', size=64),
'buyer_id':fields.many2one('res.partner', 'Buyer', required=True),
}
_defaults={
'amount':_value_amount,
'objects':_value_object,
'number':lambda *a: False,
'buyer_id':_value_buyer_id
}
auction_lots_make_invoice_buyer()
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_make_invoice_buyer" model="ir.ui.view">
<field name="name">auction.lots.make.invoice.buyer.form</field>
<field name="model">auction.lots.make.invoice.buyer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Paid">
<group colspan="4" >
<field name="amount"/>
<field name="objects"/>
<field name="number"/>
<label string="(Keep empty for automatic number)" colspan="2"/>
<field name="buyer_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" string="Create invoices" name="_makeInvoices" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_make_invoice_buyer" model="ir.actions.act_window">
<field name="name">Invoice Buyer objects</field>
<field name="res_model">auction.lots.make.invoice.buyer</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_make_invoice_buyer"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_make_invoice_buyer_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Invoice Buyer objects</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_make_invoice_buyer'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_make_invoice" model="ir.ui.view">
<field name="name">auction.lots.make.invoice.form</field>
<field name="model">auction.lots.make.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Paid">
<group colspan="4" >
<field name="amount"/>
<field name="objects"/>
<field name="number" colspan="3"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-ok" string="Create invoices" name="_makeInvoices" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_make_invoice" model="ir.actions.act_window">
<field name="name">Invoice Seller objects</field>
<field name="res_model">auction.lots.make.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_make_invoice"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_make_invoice_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Invoice Seller objects</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_make_invoice'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_lots_sms_send(osv.osv_memory):
_name = "auction.lots.sms.send"
_description = "Sms send "
_columns= {
'app_id':fields.char('API ID', size=64, required=True),
'user':fields.char('Login', size=64, required=True),
'password':fields.char('Password', size=64, required=True),
'text':fields.text('SMS Message', required=True)
}
def _sms_send(self, cr, uid, ids, context):
for datas in self.read(cr, uid, ids):
lots = self.pool.get('auction.lots').read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid'])
print "lots",lots, [l['ach_uid'][0] for l in lots if l['ach_uid']]
res = self.pool.get('res.partner').read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context)
nbr = 0
for r in res:
add = self.pool.get('res.partner').address_get(cr, uid, [r['id']])['default']
addr = self.pool.get('res.partner.address').browse(cr, uid, add)
to = addr.mobile
if to:
tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
if to:
tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
#
auction_lots_sms_send()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_lots_sms_send" model="ir.ui.view">
<field name="name">auction.lots.sms.send.form</field>
<field name="model">auction.lots.sms.send</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="SMS - Gateway: clickatell','Bulk SMS send">
<group colspan="4" >
<separator string="SMS - Gateway: clickatell','Bulk SMS send" colspan="4"/>
<field name="app_id"/>
<newline/>
<field name="user"/>
<field name="password"/>
<newline/>
<field name="text" colspan="3"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-go-back" string="Send SMS" name="_sms_send" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_lots_sms_send" model="ir.actions.act_window">
<field name="name">SMS Send</field>
<field name="res_model">auction.lots.sms.send</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_lots_sms_send"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_lots_sms_send_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">SMS Send</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_lots_sms_send'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
+105
View File
@@ -0,0 +1,105 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_pay_buy(osv.osv_memory):
def _start(self, cr, uid, context):
rec = self.pool.get('auction.lots').browse(cr, uid, context['active_ids'], context)
amount1 = 0.0
for r in rec:
amount1+= r.buyer_price
if r.is_ok:
raise osv.except_osv('Error !', 'Some lots of the selection are already paid.')
return amount1
def _value_buyer_id(self, cr, uid, context={}):
"""
For default buyer id value
@return:auction lots buyer id in buyer id field.
"""
lots= self.pool.get('auction.lots').browse(cr, uid, context['active_ids'])
for lot in lots:
buyer=lot and lot.ach_uid.id or False
return buyer
def _pay_and_reconcile(self, cr, uid, ids, context):
for datas in self.read(cr, uid, ids):
if not abs(datas['total'] - (datas['amount'] + datas['amount2'] + datas['amount3'])) <0.01:
rest = datas['total']-(datas['amount'] + datas['amount2'] + datas['amount3'])
raise osv.except_osv('Payment aborted !', 'You should pay all the total: "%.2f" are missing to accomplish the payment.' %(round(rest, 2)))
lots = self.pool.get('auction.lots').browse(cr, uid, context['active_ids'], context)
ref_bk_s = self.pool.get('account.bank.statement.line')
for lot in lots:
if datas['buyer_id']:
self.pool.get('auction.lots').write(cr, uid, [lot.id], {'ach_uid':datas['buyer_id']})
if not lot.auction_id:
raise osv.except_osv('Error !', 'No auction date for "%s": Please set one.'%(lot.name))
self.pool.get('auction.lots').write(cr, uid, [lot.id], {'is_ok':True})
for st, stamount in [('statement_id1', 'amount'), ('statement_id2', 'amount2'), ('statement_id3', 'amount3')]:
if datas[st]:
new_id = ref_bk_s.create(cr, uid, {
'name':'Buyer:'+ str(lot.ach_login or '')+', auction:'+ lots[0].auction_id.name,
'date': time.strftime('%Y-%m-%d'),
'partner_id': datas['buyer_id'] or False,
'type':'customer',
'statement_id': datas[st],
'account_id': lot.auction_id.acc_income.id,
'amount': datas[stamount]
})
for lot in lots:
self.pool.get('auction.lots').write(cr, uid, [lot.id], {'statement_id':[(4, new_id)]})
return {}
_name = "auction.pay.buy"
_description = "Pay buy"
_columns= {
'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
'buyer_id':fields.many2one('res.partner', 'Buyer'),
'statement_id1':fields.many2one('account.bank.statement', 'Statement', required=True),
'amount2': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy']))),
'statement_id2':fields.many2one('account.bank.statement', 'Statement'),
'amount3': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy']))),
'statement_id3':fields.many2one('account.bank.statement', 'Statement'),
'total': fields.float('Amount paid', digits = (16, int(tools.config['price_accuracy'])), readonly =True),
}
_defaults={
'amount' : _start,
'total' : _start,
'buyer_id' : _value_buyer_id
}
auction_pay_buy()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_pay_buy" model="ir.ui.view">
<field name="name">auction.pay.buy.form</field>
<field name="model">auction.pay.buy</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Pay objects">
<group colspan="4" >
<field name="amount"/>
<field name="statement_id1" domain="[('state','=','draft')]"/>
<field name="amount2"/>
<field name="statement_id2" domain="[('state','=','draft')]"/>
<field name="amount3"/>
<field name="statement_id3" domain="[('state','=','draft')]"/>
<newline/>
<field name="buyer_id"/>
<field name="total"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-yes" string="Pay" name="_pay_and_reconcile" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_pay_buy" model="ir.actions.act_window">
<field name="name">Pay objects of the buyer</field>
<field name="res_model">auction.pay.buy</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_pay_buy"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_pay_buy_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Pay objects of the buyer</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_pay_buy'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
+51
View File
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_pay_sel(osv.osv_memory):
_name = "auction.pay.sel"
_description = "Pay Invoice"
_columns= {
'amount': fields.float('Amount paid', digits= (16, int(tools.config['price_accuracy'])), required=True),
'dest_account_id':fields.many2one('account.account', 'Payment to Account', required=True, domain= [('type', '=', 'cash')]),
'journal_id':fields.many2one('account.journal', 'Journal', required=True),
'period_id':fields.many2one('account.period', 'Period', required=True),
}
def _pay_and_reconcile(self, cr, uid, ids, context):
lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context)
for datas in self.read(cr, uid, ids):
account_id = datas.get('writeoff_acc_id', False)
period_id = datas.get('period_id', False)
journal_id = datas.get('journal_id', False)
if lot.sel_inv_id:
p = self.pool.get('account.invoice').pay_and_reconcile(['lot.sel_inv_id.id'], datas['amount'], datas['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
# lots.sel_inv_id.pay_and_reconcile(cr,uid,data[id], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
return {}
auction_pay_sel()
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_pay_sel" model="ir.ui.view">
<field name="name">auction.pay.sel.form</field>
<field name="model">auction.pay.sel</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Pay invoice">
<group colspan="4" >
<field name="amount"/>
<field name="dest_account_id"/>
<field name="journal_id"/>
<field name="period_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-yes" string="Pay" name="_pay_and_reconcile" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_pay_sel" model="ir.actions.act_window">
<field name="name">Pay objects of the seller</field>
<field name="res_model">auction.pay.sel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_pay_sel"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -19,43 +19,42 @@
#
##############################################################################
import wizard
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
#field name="confirm_en"/>
import time
import tools
import wizard
take_form = """<?xml version="1.0"?>
<form title="Confirm">
<separator string="Confirmation enable taken away" colspan="4"/>
<newline/>
</form>
"""
class auction_payer(osv.osv_memory):
take_fields = {
'confirm_en': {'string':'Catalog Number', 'type':'integer'},
}
def _confirm_enable(self,cr,uid,data,context={}):
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':False})
return {}
class enable_take_away(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {
'type' : 'form',
'arch' : take_form,
'fields' : take_fields,
'state' : [ ('end', 'Cancel'),('go', 'Enable Taken away')]}
},
'go' : {
'actions' : [_confirm_enable],
'result' : {'type' : 'state', 'state' : 'end'}
},
}
enable_take_away('auction.lots.enable')
_name = "auction.payer"
_description = "Auction payer"
def _payer(self, cr, uid, ids, context):
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'is_ok':True, 'state':'paid'})
return {}
auction_payer()
class auction_payer_sel(osv.osv_memory):
"""
For Mark as payment for seller
"""
_name = "auction.payer.sel"
_description = "Auction payment for seller"
def _payer_sel(self, cr, uid, ids, context):
"""
This function Update auction lots object and seller paid true.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of auction payer sel’s IDs.
"""
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'paid_vnd':True})
return {}
auction_payer_sel()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_payer" model="ir.ui.view">
<field name="name">auction.payer.form</field>
<field name="model">auction.payer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Check payment for buyer">
<separator string="" colspan="4" />
<group colspan="4" col="2">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon = "gtk-yes" string="Pay" name="_payer" type="object"/>
</group>
</form>
</field>
</record>
<record id="view_auction_payer_sel" model="ir.ui.view">
<field name="name">auction.payer.sel.form</field>
<field name="model">auction.payer.sel</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Check payment for seller">
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-yes" string="Pay" name="_payer_sel" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_auction_payer_sel" model="ir.actions.act_window">
<field name="name">Mark as paid for seller</field>
<field name="res_model">auction.payer.sel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_payer_sel"/>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record id="auction_payer_sel_values" model="ir.values">
<field name="model_id" ref="auction.model_auction_lots" />
<field name="object" eval="1" />
<field name="name">Mark as paid for seller</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_auction_payer_sel'))" />
<field name="key">action</field>
<field name="model">auction.lots</field>
</record>
</data>
</openerp>
+57
View File
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class auction_taken(osv.osv_memory):
"""
Auction lots taken.
"""
_name = "auction.taken"
_description = "Auction taken"
_columns = {
'lot_ids':fields.many2many('auction.lots', 'auction_taken_rel', 'taken_id', 'lot_id', 'Lots Emportes'),
}
def _to_xml(s):
return s.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')
def _process(self, cr, uid, ids, context):
"""
Update Auction lots state to taken_away.
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: List of Auction taken’s IDs
@return: dictionary of lot_ids fields with empty list
"""
for data in self.read(cr, uid, ids):
lot_obj = self.pool.get('auction.lots')
if data['lot_ids']:
lot_obj.write(cr, uid, data['lot_ids'], {'state':'taken_away'})
return {'lot_ids': []}
auction_taken()
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_auction_taken" model="ir.ui.view">
<field name="name">auction.taken.form</field>
<field name="model">auction.taken</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Mark Lots">
<group colspan="4" >
<label string="Select lots which are Sold" colspan="4"/>
<field name="lot_ids" nolabel="1" colspan="4" domain="[('state','=','sold')]"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-ok" string="OK" name="_process" type="object" />
</group>
</form>
</field>
</record>
<record id="action_auction_taken" model="ir.actions.act_window">
<field name="name">Gestion emporte</field>
<field name="res_model">auction.taken</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_auction_taken"/>
<field name="target">new</field>
</record>
<!-- <menuitem name="Tools Bar Codes"
id="auction_outils_menu"
parent="auction_menu_root" sequence="5"
/>
<menuitem name="Deliveries Management"
action="action_auction_taken"
id="menu_wizard_emporte"
parent="auction_outils_menu"
/> -->
</data>
</openerp>
@@ -1,111 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
invoice_form = '''<?xml version="1.0"?>
<form title="Paid ?">
<field name="amount"/>
<field name="objects"/>
<field name="number"/>
<label string="(Keep empty for automatic number)" colspan="2"/>
<field name="buyer_id"/>
</form>'''
invoice_fields = {
'amount': {'string':'Invoiced Amount', 'type':'float', 'required':True, 'readonly':True},
'objects': {'string':'# of objects', 'type':'integer', 'required':True, 'readonly':True},
'number': {'string':'Invoice Number', 'type':'char'},
'buyer_id':{'string': 'Buyer', 'type': 'many2one', 'relation':'res.partner'}
}
def _values(self,cr,uid, datas,context={}):
pool = pooler.get_pool(cr.dbname)
lots= pool.get('auction.lots').browse(cr,uid,datas['ids'])
# price = 0.0
amount_total=0.0
# pt_tax=pooler.get_pool(cr.dbname).get('account.tax')
for lot in lots:
buyer=lot and lot.ach_uid.id or False
amount_total+=lot.buyer_price
# taxes = lot.product_id.taxes_id
# if lot.author_right:
# taxes.append(lot.author_right)
# if lot.auction_id:
# taxes += lot.auction_id.buyer_costs
# tax=pt_tax.compute(cr,uid,taxes,lot.obj_price,1)
# for t in tax:
# amount_total+=t['amount']
# amount_total+=lot.obj_price
# up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[lot.id],{'ach_uid':datas['form']['buyer_id']})
invoice_number = False
return {'objects':len(datas['ids']), 'amount':amount_total, 'number':invoice_number,'buyer_id':buyer}
def _makeInvoices(self, cr, uid, data, context):
newinv = []
pool = pooler.get_pool(cr.dbname)
order_obj = pool.get('auction.lots')
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
lots= order_obj.browse(cr,uid,data['ids'])
invoice_number=data['form']['number']
for lot in lots:
up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[lot.id],{'ach_uid':data['form']['buyer_id']})
ids = order_obj.lots_invoice(cr, uid, data['ids'],context,data['form']['number'])
# ids = order_obj.lots_invoice(cr, uid, data['ids'],context,invoice_number)
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Buyer invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'in_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
return {}
class make_invoice(wizard.interface):
states = {
'init' : {
'actions' : [_values],
'result' : {'type' : 'form',
'arch' : invoice_form,
'fields' : invoice_fields,
'state' : [('end', 'Cancel'),('invoice', 'Create invoices')]}
},
'invoice' : {
'actions' : [],
'result' : {'type' : 'action',
'action' : _makeInvoices}
},
}
make_invoice("auction.lots.make_invoice_buyer")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,105 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
invoice_form = '''<?xml version="1.0"?>
<form title="Paid ?">
<field name="amount"/>
<field name="objects"/>
<field name="number" colspan="3"/>
</form>'''
invoice_fields = {
'amount': {'string':'Invoiced Amount', 'type':'float', 'required':True, 'readonly':True},
'objects': {'string':'# of objects', 'type':'integer', 'required':True, 'readonly':True},
'number': {'string':'Invoice Number', 'type':'integer'},
}
def _values(self,cr,uid, datas,context={}):
lots= pooler.get_pool(cr.dbname).get('auction.lots').browse(cr,uid,datas['ids'])
# service = netsvc.LocalService("object_proxy")
# lots = service.execute(cr,uid, 'auction.lots', 'read', datas['ids'])
# auction = service.execute(cr,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0]
price = 0.0
amount_total=0.0
pt_tax=pooler.get_pool(cr.dbname).get('account.tax')
for lot in lots:
# taxes = lot.product_id.taxes_id
# if lot.bord_vnd_id.tax_id:
# taxes.append(lot.bord_vnd_id.tax_id)
# if lot.auction_id:
# taxes += lot.auction_id.seller_costs
# tax=pt_tax.compute(cr,uid,taxes,lot.obj_price,1)
# for t in tax:
# amount_total+=t['amount']
# amount_total+=lot.obj_price
amount_total+=lot.seller_price
#TODO: recuperer id next invoice (de la sequence)???
invoice_number = False
return {'objects':len(datas['ids']), 'amount':amount_total, 'number':invoice_number}
def _makeInvoices(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
order_obj = pool.get('auction.lots')
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id'])
newinv = []
ids = order_obj.seller_trans_create(cr, uid, data['ids'],context)
cr.commit()
return {
'domain': "[('id','in', ["+','.join(map(str, ids))+"])]",
'name': 'Seller invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
return {}
class make_invoice(wizard.interface):
states = {
'init' : {
'actions' : [_values],
'result' : {'type' : 'form',
'arch' : invoice_form,
'fields' : invoice_fields,
'state' : [('end', 'Cancel'),('invoice', 'Create invoices')]}
},
'invoice' : {
'actions' : [_makeInvoices],
'result' : {'type' : 'action',
'action' : _makeInvoices,
'state' : 'end'}
},
}
make_invoice("auction.lots.make_invoice")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-73
View File
@@ -1,73 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
from tools.misc import UpdateableStr
# Dossier
_lot_arch = """<?xml version="1.0"?>
<form string="Mark Lots" height="500" width="1000">
<label string="Select lots which are Sold" colspan="4"/>
<field name="lot_ids" nolabel="1" colspan="4" domain="[('state','=','sold')]"/>
</form>
"""
_lot_fields = {
'lot_ids': {'string':'Lots Emportes','relation':'auction.lots','type':'many2many'}
}
def _to_xml(s):
return s.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;')
def _process(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
lot_obj = pool.get('auction.lots')
if data['form']['lot_ids']:
lot_obj.write(cr, uid, data['form']['lot_ids'][0][2], {'state':'taken_away'})
return {'lot_ids': []}
class wizard_reprint(wizard.interface):
states = {
'valid': {
'actions': [_process],
'result': {'type':'state', 'state':'init'}
},
'init': {
'actions': [],
'result': {
'type':'form',
'arch': _lot_arch,
'fields': _lot_fields,
'state': [
('valid',' OK ')
],
}
}
}
wizard_reprint('auction.taken')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,96 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
import sql_db
auction_move = '''<?xml version="1.0"?>
<form string="Change Auction Date">
<group col="1" colspan="2">
<label string="Warning, this will erase the object adjudication price and its buyer !" colspan="2"/>
</group>
<newline/>
<field name="auction_id"/>
</form>'''
auction_move_fields = {
'auction_id': {'string':'Auction Date', 'type':'many2one', 'required':True, 'relation':'auction.dates'},
}
#def _auction_move_set(self, uid, datas):
# if datas['form']['auction_id']:
# cr = sql_db.db.cursor()
# cr.execute('update auction_lots set auction_id=%s, obj_price=NULL, ach_login=NULL, ach_uid=NULL, ach_pay_id=NULL, ach_inv_id=NULL, state=%s where id in ('+','.join(map(str, datas['ids']))+')', (str(datas['form']['auction_id']), 'draft'))
# cr.execute('delete from auction_bid_line where lot_id in ('+','.join(map(str, datas['ids']))+')')
# cr.commit()
# cr.close()
# return {}
def _top(self,cr,uid,datas,context={}):
refs = pooler.get_pool(cr.dbname).get('auction.lots')
rec_ids = refs.browse(cr,uid,datas['ids'])
for rec in rec_ids:
if not rec.auction_id:
raise wizard.except_wizard('Error !','You can not move a lot that has no auction date')
return {}
def _auction_move_set(self,cr,uid,datas,context={}):
if not (datas['form']['auction_id'] and len(datas['ids'])) :
return {}
refs = pooler.get_pool(cr.dbname).get('auction.lots')
rec_ids = refs.browse(cr,uid,datas['ids'])
line_ids= pooler.get_pool(cr.dbname).get('auction.bid_line').search(cr,uid,[('lot_id','in',datas['ids'])])
# pooler.get_pool(cr.dbname).get('auction.bid_line').unlink(cr, uid, line_ids)
for rec in rec_ids:
new_id=pooler.get_pool(cr.dbname).get('auction.lot.history').create(cr,uid,{
'auction_id':rec.auction_id.id,
'lot_id':rec.id,
'price': rec.obj_ret
})
up_auction=pooler.get_pool(cr.dbname).get('auction.lots').write(cr,uid,[rec.id],{
'auction_id':datas['form']['auction_id'],
'obj_ret':None,
'obj_price':None,
'ach_login':None,
'ach_uid':None,
'ach_inv_id':None,
'sel_inv_id':None,
'obj_num':None,
'state':'draft'})
return {}
class wiz_auc_lots_auction_move(wizard.interface):
states = {
'init': {
'actions': [_top],
'result': {'type': 'form', 'arch':auction_move, 'fields': auction_move_fields, 'state':[('set_date', 'Move to Auction date'),('end','Cancel')]}
},
'set_date': {
'actions': [_auction_move_set],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_auc_lots_auction_move('auction.lots.auction_move')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-103
View File
@@ -1,103 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import netsvc
import osv
import time
import pooler
invoice_form = '''<?xml version="1.0"?>
<form string="Pay invoice">
<field name="amount"/>
<field name="dest_account_id"/>
<field name="journal_id"/>
<field name="period_id"/>
</form>'''
invoice_fields = {
'amount': {'string': 'Amount paid', 'type':'float', 'required':True},
'dest_account_id': {'string':'Payment to Account', 'type':'many2one', 'required':True, 'relation':'account.account', 'domain':[('type','=','cash')]},
'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
}
#def pay_n_check(self, cr, uid, data, context):
#
# auction = pool.get('auction.lots').browse(cr,uid,data['id'],context)
# try:
#
# for lot in auction:
#
# if not lot.auction_id :
# raise osv.except_osv("Error","No payment defined for this auction.")
# i=1
# tot= 0
# for payment in auction:
# if not payment.journal_id :
# raise osv.except_osv("Error","No journal defined for the payment line %d" % (i,))
# if not payment.ach_inv_id.amount :
# raise osv.except_osv("Error","No amount defined for the payment line %d." % (i,))
# i+=1
# tot+= payment.ach_inv_id.amount
# if abs(float(tot)) - abs(float(lot.obj_ret)) > 10**-6:
# raise osv.except_osv("Error","The amount paid does not match the total amount")
# else:
# for lot in auction:
# if not lot.journal_id :
# raise osv.except_osv("Error","Please choose a journal for the auction ("+lot.name+").")
# pool.get('auction.lots').create(cr,uid,{
# 'auction_id': lot.auction.id,
# 'journal_id': lot.journal_id,
#
# })
# except osv.except_osv, e:
# raise wizard.except_wizard(e.name, e.name)
# return True
def _pay_and_reconcile(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
lot = pool.get('auction.lots').browse(cr,uid,data['id'],context)
form = data['form']
account_id = form.get('writeoff_acc_id', False)
period_id = form.get('period_id', False)
journal_id = form.get('journal_id', False)
if lot.sel_inv_id:
p=pool.get('account.invoice').pay_and_reconcile(['lot.sel_inv_id.id'], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
# lots.sel_inv_id.pay_and_reconcile(cr,uid,data[id], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
return {}
class wiz_auc_lots_pay(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':invoice_form, 'fields': invoice_fields, 'state':[ ('pay','Pay'), ('end','Cancel')]}
},
'pay': {
'actions': [_pay_and_reconcile],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_lots_pay('auction.pay.sel');
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-150
View File
@@ -1,150 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import urllib
sms_send_form = '''<?xml version="1.0"?>
<form title="%s">
<separator string="%s" colspan="4"/>
<field name="app_id"/>
<newline/>
<field name="user"/>
<field name="password"/>
<newline/>
<field name="text" colspan="3"/>
</form>''' % ('SMS - Gateway: clickatell', 'Bulk SMS send')
sms_send_fields = {
'app_id': {'string':'API ID', 'type':'char', 'required':True},
'user': {'string':'Login', 'type':'char', 'required':True},
'password': {'string':'Password', 'type':'char', 'required':True},
'text': {'string':'SMS Message', 'type':'text', 'required':True, 'value':'Les lots [lots] vous ont etes adjuges. -- Rops'}
}
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import pooler
sms_send_form = '''<?xml version="1.0"?>
<form string="%s">
<separator string="%s" colspan="4"/>
<field name="app_id"/>
<newline/>
<field name="user"/>
<field name="password"/>
<newline/>
<field name="text" colspan="3"/>
</form>''' % ('SMS - Gateway: clickatell','Bulk SMS send')
sms_send_fields = {
'app_id': {'string':'API ID', 'type':'char', 'required':True},
'user': {'string':'Login', 'type':'char', 'required':True},
'password': {'string':'Password', 'type':'char', 'required':True},
'text': {'string':'SMS Message', 'type':'text', 'required':True}
}
def _sms_send(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', data['ids'], ['obj_num','obj_price','ach_uid'])
res = service.execute(cr.dbname,uid, 'res.partner', 'read', [l['ach_uid'] for l in lots if l['ach_uid']], ['gsm'])
#res = service.execute(cr.dbname, uid, 'res.partner', 'read', data['ids'], ['gsm'])
# service = netsvc.LocalService("object_proxy")
# pool=pooler.get_pool(cr.dbname)
# lots=pool.get('auction.lots').browse(cr,uid,data['id'],context)
# r=lots.ach_uid.id
nbr = 0
for r in res:
to = r['mobile']
if to:
tools.smssend(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
if to:
tools.smssend(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('latin1'), to)
nbr += 1
return {'sms_sent': nbr}
#
#def _sms_send(self, uid, datas):
# service = netsvc.LocalService("object_proxy")
# pool=pooler.ger_pool(cr.dbname)
# lots=pool.get('auction.lots').browse(cr,uid,datas['ids'],context)
# #lots = service.execute(uid, 'auction.lots', 'read', datas['ids'], ['obj_num','obj_price','ach_uid'])
# #part = service.execute(uid, 'res.partner', 'read', [l['ach_uid'] for l in lots if l['ach_uid']], ['gsm'])
#
# part =ach_uid.id
# part = map(lambda x: (x.id,x.mobile), part)
# for l in lots:
# part.append(str(l.obj_num)+'-%dEUR' % int(l.obj_price))
#
# for p in part.values():
# to = p.mobile
# if to:
# params = urllib.urlencode({'user': datas['form']['user'], 'password': datas['form']['password'], 'api_id': datas['form']['app_id'], 'text':unicode(datas['form']['text'].replace('[lots]',', '.join(p['lots'])), 'utf-8').encode('latin1'), 'to':to})
# f = urllib.urlopen("http://196.7.150.220/http/sendmsg", params)
# nbr+=1
# return {'sms_sent':nbr}
class lots_sms(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':sms_send_form, 'fields': sms_send_fields, 'state':[('send','Send SMS'), ('end','Cancel')]}
},
'send': {
'actions': [_sms_send],
'result': {'type': 'state', 'state':'end'}
}
}
lots_sms('auction.lots.sms_send');
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-109
View File
@@ -1,109 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import netsvc
import osv
import time
import pooler
pay_form = '''<?xml version="1.0"?>
<form string="Pay objects">
<field name="amount"/>
<field name="statement_id1" domain="[('state','=','draft')]"/>
<field name="amount2"/>
<field name="statement_id2" domain="[('state','=','draft')]"/>
<field name="amount3"/>
<field name="statement_id3" domain="[('state','=','draft')]"/>
<newline/>
<field name="buyer_id"/>
<field name="total"/>
</form>'''
def _start(self,cr,uid,data,context):
pool = pooler.get_pool(cr.dbname)
rec=pool.get('auction.lots').browse(cr,uid,data['ids'],context)
amount1=0.0
for r in rec:
amount1+=r.buyer_price
buyer= r and r.ach_uid.id or False
if r.is_ok:
raise wizard.except_wizard('Error !', 'Some lots of the selection are already paid.')
return {'amount':amount1, 'total':amount1,'buyer_id':buyer}
pay_fields = {
'amount': {'string': 'Amount paid', 'type':'float'},
'buyer_id': {'string': 'Buyer', 'type': 'many2one', 'relation':'res.partner'},
'statement_id1': {'string':'Statement', 'type':'many2one', 'required':True, 'relation':'account.bank.statement'},
'amount2': {'string': 'Amount paid', 'type':'float'},
'statement_id2': {'string':'Statement', 'type':'many2one', 'relation':'account.bank.statement'},
'amount3': {'string': 'Amount paid', 'type':'float'},
'statement_id3': {'string':'Statement', 'type':'many2one', 'relation':'account.bank.statement'},
'total': {'string': 'Amount to paid', 'type':'float','readonly':True}
}
def _pay_and_reconcile(self, cr, uid, data, context):
if not abs(data['form']['total'] - (data['form']['amount']+data['form']['amount2']+data['form']['amount3']))<0.01:
rest=data['form']['total']-(data['form']['amount']+data['form']['amount2']+data['form']['amount3'])
raise wizard.except_wizard('Payment aborted !', 'You should pay all the total: "%.2f" are missing to accomplish the payment.' %(round(rest,2)))
pool = pooler.get_pool(cr.dbname)
lots = pool.get('auction.lots').browse(cr,uid,data['ids'],context)
ref_bk_s=pooler.get_pool(cr.dbname).get('account.bank.statement.line')
for lot in lots:
if data['form']['buyer_id']:
pool.get('auction.lots').write(cr,uid,[lot.id],{'ach_uid':data['form']['buyer_id']})
if not lot.auction_id:
raise wizard.except_wizard('Error !', 'No auction date for "%s": Please set one.'%(lot.name))
pool.get('auction.lots').write(cr,uid,[lot.id],{'is_ok':True})
for st,stamount in [('statement_id1','amount'),('statement_id2','amount2'),('statement_id3','amount3')]:
if data['form'][st]:
new_id=ref_bk_s.create(cr,uid,{
'name':'Buyer:'+str(lot.ach_login or '')+', auction:'+ lots[0].auction_id.name,
'date': time.strftime('%Y-%m-%d'),
'partner_id':data['form']['buyer_id'] or False,
'type':'customer',
'statement_id':data['form'][st],
'account_id':lot.auction_id.acc_income.id,
'amount':data['form'][stamount]
})
for lot in lots:
pool.get('auction.lots').write(cr,uid,[lot.id],{'statement_id':[(4,new_id)]})
return {}
class wiz_auc_lots_pay(wizard.interface):
states = {
'init': {
'actions': [_start],
'result': {'type': 'form', 'arch':pay_form, 'fields': pay_fields, 'state':[('end','Cancel'),('pay','Pay')]}
},
'pay': {
'actions': [_pay_and_reconcile],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_lots_pay('auction.pay.buy')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-79
View File
@@ -1,79 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import netsvc
import osv
import time
import pooler
pay_form = '''<?xml version="1.0"?>
<form string="Check payment for buyer">
</form>'''
pay_fields = {
}
pay_form1 = '''<?xml version="1.0"?>
<form string="Check payment for seller">
</form>'''
pay_fields1 = {
}
def _payer(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'is_ok':True, 'state':'paid'})
return {}
def _payer_sel(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
pool.get('auction.lots').write(cr,uid,data['ids'],{'paid_vnd':True})
return {}
class wiz_auc_pay(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':pay_form, 'fields': pay_fields, 'state':[('end','Cancel'),('pay','Pay')]}
},
'pay': {
'actions': [_payer],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_pay('auction.payer')
class wiz_auc_pay_sel(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':pay_form1, 'fields': pay_fields1, 'state':[('end','Cancel'),('pay2','Pay')]}
},
'pay2': {
'actions': [_payer_sel],
'result': {'type': 'state', 'state':'end'}
}}
wiz_auc_pay_sel('auction.payer.sel')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -31,6 +31,7 @@
'depends': ['base'],
'init_xml': [],
'update_xml': [
'wizard/audittrail_view_log_view.xml',
'audittrail_view.xml',
'security/ir.model.access.csv',
'security/audittrail_security.xml'
+2 -2
View File
@@ -124,8 +124,8 @@
</record>
<menuitem name="Logs" id="menu_action_audittrail_log_tree" action="action_audittrail_log_tree" parent="menu_action_audittrail"/>
<wizard string="View log" menu="False" model="audittrail.log" name="audittrail.view.log" id="wizard_audittrail_log"/>
<menuitem name="View Logs" id="menu_action_log_tree2" action="wizard_audittrail_log" type="wizard" parent="menu_action_audittrail"/>
<!-- <wizard string="View log" menu="False" model="audittrail.log" name="audittrail.view.log" id="wizard_audittrail_log"/>-->
<menuitem name="View Logs" id="menu_action_log_tree2" action="action_audittrail_view_log" parent="menu_action_audittrail"/>
</data>
</openerp>
+1 -1
View File
@@ -19,6 +19,6 @@
#
##############################################################################
import wizard_view_log
import audittrail_view_log
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class audittrail_view_log(osv.osv_memory):
_name = "audittrail.view.log"
_description = "View Log"
_columns ={
'from':fields.datetime('Log From'),
'to':fields.datetime('Log To', required = True)
}
_defaults = {
'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
}
def log_open_window(self, cr, uid, ids, context):
"""
Open Log form from given date range..
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of audittrail view log’s IDs.
@return: Dictionary of audittrail log form on given date range.
"""
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
log_obj= self.pool.get(result['res_model'])
log_id = log_obj.search(cr, uid, [])
log_model=log_obj.read(cr, uid,log_id,['object_id'])
for datas in self.read(cr, uid, ids):
if not datas['from']:
if datas['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
result['domain'] = str([('timestamp', '<',datas['to'])])
else:
pass
else:
result['domain'] = str([('timestamp', '>',datas['from']),('timestamp', '<',datas['to'])])
return result
audittrail_view_log()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_audittrail_view_log" model="ir.ui.view">
<field name="name">audittrail.view.log.form</field>
<field name="model">audittrail.view.log</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Audit Logs">
<group colspan="4" >
<field name="from" colspan="4"/>
<newline/>
<field name="to" colspan="4"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open Logs" name="log_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_audittrail_view_log" model="ir.actions.act_window">
<field name="name">View log</field>
<field name="res_model">audittrail.view.log</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_audittrail_view_log"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,81 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import time
class wizard_view_log(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Audit Logs">
<field name="from" colspan="4"/>
<newline/>
<field name="to" colspan="4"/>
</form>'''
form1_fields = {
'from': {
'string': 'Log From',
'type': 'datetime',
},
'to': {
'string': 'Log To',
'type': 'datetime',
'default': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'required':True
},
}
def _log_open_window(self, cr, uid, data, context):
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
log_obj= pooler.get_pool(cr.dbname).get(result['res_model'])
log_id = log_obj.search(cr, uid, [])
log_model=log_obj.read(cr, uid,log_id,['object_id'])
if not data['form']['from']:
if data['form']['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
result['domain'] = str([('timestamp', '<',data['form']['to'])])
else:
pass
else:
result['domain'] = str([('timestamp', '>',data['form']['from']),('timestamp', '<',data['form']['to'])])
return result
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel'), ('open', 'Open Logs')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action':_log_open_window, 'state':'end'}
}
}
wizard_view_log('audittrail.view.log')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -1
View File
@@ -40,7 +40,8 @@
],
"demo_xml" : [],
"update_xml" : [
'security/ir.model.access.csv',
'security/ir.model.access.csv',
'wizard/calendar_event_edit_all_view.xml',
'base_calendar_view.xml'
],
"installable" : True,
+2 -1
View File
@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_cal_edit_event
import calendar_event_edit_all
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class calendar_event_edit_all(osv.osv_memory):
def _default_values(self, cr, uid, context={}):
"""
@Return : Get Default value for Start Date
"""
if context.get('date'):
return context.get('date')
else:
model = context.get('model')
model_obj = self.pool.get(model)
event = model_obj.read(cr, uid, context['active_id'], ['name', 'location', 'alarm_id'])
return event['date']
def _default_deadline(self, cr, uid, context={}):
"""
@return : Get Default value for End Date
"""
if context.get('date_deadline'):
return context.get('date_deadline')
else:
model = context.get('model')
model_obj = self.pool.get(model)
event = model_obj.read(cr, uid, context['active_id'], ['name', 'location', 'alarm_id'])
return event['date_deadline']
def _modify_this(self, cr, uid, ids, context=None):
"""
Modify All event for Crm Meeting.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of calendar event edit all’s IDs
"""
for datas in self.read(cr, uid, ids):
model = context.get('model')
model_obj = self.pool.get(model)
model_obj.modify_all(cr, uid, [context['active_id']], datas, context)
return {}
_name = "calendar.event.edit.all"
_description = "Calendar Edit all event"
_columns ={
'name':fields.char('Title', size=64, required=True),
'date':fields.datetime('Start Date', required=True),
'date_deadline':fields.datetime('End Date', required=True),
'location':fields.char('Location', size=124),
'alarm_id':fields.many2one('res.alarm', 'Reminder'),
}
_defaults = {
'date':_default_values,
'date_deadline':_default_deadline
}
calendar_event_edit_all()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_calendar_event_edit_all" model="ir.ui.view">
<field name="name">calendar.event.edit.all.form</field>
<field name="model">calendar.event.edit.all</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Edit all Occurrences">
<group colspan="4" >
<separator string="" colspan="4" />
<newline/>
<field name='name' colspan="4" />
<newline />
<field name='location' colspan="4" />
<newline />
<field name='date' />
<field name='date_deadline' />
<newline />
<field name='alarm_id'/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-save" string="_Save" name="_modify_this" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_calendar_event_edit_all" model="ir.actions.act_window">
<field name="name">Edit all events</field>
<field name="res_model">calendar.event.edit.all</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_calendar_event_edit_all"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,78 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
class event_edit_all(wizard.interface):
event_form = """<?xml version="1.0"?>
<form string="Edit all Occurrences">
<separator string="" colspan="4" />
<newline />
<field name='name' colspan="4" />
<newline />
<field name='location' colspan="4" />
<newline />
<field name='date' />
<field name='date_deadline' />
<newline />
<field name='alarm_id'/>
</form>"""
event_fields = {
'name': {'string': 'Title', 'type': 'char', 'size': 64, 'required': True},
'date': {'string': 'Start Date', 'type': 'datetime', 'required': True},
'date_deadline': {'string': 'End Date', 'type': 'datetime', 'required': True},
'location': {'string': 'Location', 'type': 'char', 'size': 124},
'alarm_id': {'string': 'Reminder', 'type': 'many2one', 'relation': 'res.alarm'},
}
def _default_values(self, cr, uid, data, context=None):
model = data.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
event = model_obj.read(cr, uid, data['id'], ['name', 'location', 'alarm_id'])
event.update({
'date': context.get('date'),
'date_deadline': context.get('date_deadline')
})
return event
def _modify_all(self, cr, uid, datas, context=None):
model = datas.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
model_obj.modify_all(cr, uid, datas['id'], datas['form'], context)
return {}
states = {
'init': {
'actions': [_default_values],
'result': {'type': 'form', 'arch': event_form, 'fields': event_fields,
'state': [('end', 'Cancel', 'gtk-cancel'), ('edit', '_Save', 'gtk-save')]}
},
'edit': {
'actions': [],
'result': {'type': 'action', 'action': _modify_all, 'state': 'end'}
}
}
event_edit_all('calendar.event.edit.all')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -37,6 +37,7 @@ the "Dashboard" menu.
'init_xml': [],
'update_xml': [
'security/ir.model.access.csv',
'wizard/report_menu_create_view.xml',
'base_report_creator_wizard.xml',
'base_report_creator_view.xml'
],
@@ -41,7 +41,7 @@
<field name="model_ids" colspan="4" context="{'model_ids':model_ids}"/>
<separator string="State" colspan="4"/>
<field name="state"/>
<button string="Create Menu" name="%(wizard_menu_create)d" type="action" colspan="2" icon="gtk-justify-fill"/>
<button string="Create Menu" name="%(action_report_menu_create)d" type="action" colspan="2" icon="gtk-justify-fill"/>
</page><page string="View parameters">
<separator string="Used View" colspan="4"/>
<field name="view_type1"/>
@@ -1,13 +1,8 @@
<?xml version="1.0"?>
<openerp>
<data>
<wizard
id="wizard_set_filter_fields"
string="Set Filter Fields"
name="base_report_creator.report_filter.fields"/>
<wizard
id="wizard_menu_create"
string="Create Menu for Report"
name="base_report_creator.report.menu.create"/>
</data>
<data>
<wizard id="wizard_set_filter_fields" string="Set Filter Fields"
name="base_report_creator.report_filter.fields" />
</data>
</openerp>
@@ -22,5 +22,6 @@
import wiz_set_filter_fields
import base_report_creator_open
import report_menu_create
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -20,62 +20,55 @@
##############################################################################
import time
import wizard
import osv
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
section_form = '''<?xml version="1.0"?>
<form string="Create Menu For This Report">
<separator string="Menu Information" colspan="4"/>
<field name="menu_name"/>
<field name="menu_parent_id"/>
</form>'''
section_fields = {
'menu_name': {'string':'Menu Name', 'type':'char', 'required':True, 'size':64},
'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True},
}
def report_menu_create(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
board = pool.get('base_report_creator.report').browse(cr, uid, data['id'])
view = board.view_type1
if board.view_type2:
view+=','+board.view_type2
if board.view_type3:
view+=','+board.view_type3
action_id = pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name,
'view_type':'form',
'view_mode':view,
'context': "{'report_id':%d}" % (board.id,),
'res_model': 'base_report_creator.report'
})
pool.get('ir.ui.menu').create(cr, uid, {
'name': data['form']['menu_name'],
'parent_id': data['form']['menu_parent_id'],
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
}, context)
return {}
class wizard_section_menu_create(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]}
},
'create_menu': {
'actions': [report_menu_create],
'result': {
'type':'state',
'state':'end'
}
}
}
wizard_section_menu_create('base_report_creator.report.menu.create')
class report_menu_create(osv.osv_memory):
"""
Create Menu
"""
_name = "report.menu.create"
_description = "Menu Create"
_columns ={
'menu_name':fields.char('Menu Name', size=64, required=True),
'menu_parent_id':fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
}
def report_menu_create(self, cr, uid, ids, context):
"""
Create Menu.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Report Menu Create's IDs
"""
board = self.pool.get('base_report_creator.report').browse(cr, uid, context['active_id'])
view = board.view_type1
if board.view_type2:
view+=','+board.view_type2
if board.view_type3:
view+=','+board.view_type3
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name,
'view_type':'form',
'view_mode':view,
'context': "{'report_id':%d}" % (board.id,),
'res_model': 'base_report_creator.report'
})
for data in self.read(cr, uid, ids):
self.pool.get('ir.ui.menu').create(cr, uid, {
'name': data['menu_name'],
'parent_id': data['menu_parent_id'],
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
}, context)
return {}
report_menu_create()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_report_menu_create" model="ir.ui.view">
<field name="name">report.menu.create.form</field>
<field name="model">report.menu.create</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Menu For This Report">
<group colspan="4" >
<separator string="Menu Information" colspan="4"/>
<field name="menu_name"/>
<field name="menu_parent_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-save" string="Create Menu" name="report_menu_create" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_report_menu_create" model="ir.actions.act_window">
<field name="name">Create Menu for Report</field>
<field name="res_model">report.menu.create</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_report_menu_create"/>
<field name="target">new</field>
</record>
</data>
</openerp>
-1
View File
@@ -77,7 +77,6 @@ between mails and Open ERP.""",
#'crm_lead_wizard.xml',
'crm_lead_view.xml',
'crm_lead_menu.xml',
'crm_meeting_wizard.xml',
'crm_meeting_view.xml',
'crm_meeting_menu.xml',
#'crm_phonecall_wizard.xml',
+1 -1
View File
@@ -38,7 +38,7 @@
<field name="rrule_type" string="Recurrency"
colspan="1" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
<button string="Edit All" help="Edit all Ourrences of recurrent Meeting" attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
name="%(wizard_edit_all_events)d" icon="gtk-edit"
name="%(base_calendar.action_calendar_event_edit_all)d" icon="gtk-edit"
type="action" context="{'model' : 'crm.meeting', 'date': date, 'date_deadline': date_deadline}" />
</group>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard string="Edit all events" model="crm.meeting"
name="calendar.event.edit.all" id="wizard_edit_all_events"
menu="False" />
</data>
</openerp>
+2
View File
@@ -26,4 +26,6 @@ import wizard
import report
import company
import schedulers
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+3
View File
@@ -69,6 +69,9 @@
'process/service_product_process.xml',
'process/procurement_process.xml',
'mrp_installer.xml',
'make_procurement.xml',
'orderpoint_procurement.xml',
'schedulers_all.xml',
],
'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml'],
'installable': True,
+51
View File
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Make Procurement -->
<record id="view_make_procurment_wizard" model="ir.ui.view">
<field name="name">Requisition Request</field>
<field name="model">make.procurement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Requisition Request">
<label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." colspan="4"/>
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="qty"/>
<field name="uom_id"/>
<field name="date_planned"/>
<field name="warehouse_id" colspan="4"/>
<newline/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="make_procurement" string="Ask New Products"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_make_procurement" model="ir.actions.act_window">
<field name="name">Requisition Request</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">make.procurement</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record model="ir.values" id="make_procurement_products">
<field name="model_id" ref="product.model_product_product" />
<field name="object" eval="1" />
<field name="name">Requisition Request</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_make_procurement'))" />
<field name="key">action</field>
<field name="model">product.product</field>
</record>
</data>
</openerp>
+7 -7
View File
@@ -8,7 +8,7 @@
<menuitem action="wiz_mrp_proc1" id="menu_wiz_mrp_proc1" parent="mrp.mrp_Sched_all" type="wizard"/>
-->
<wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/>
<!-- <wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/>-->
<!--
<menuitem action="wiz_mrp_proc2" id="menu_wiz_mrp_proc2" parent="mrp.mrp_Sched_all" type="wizard"/>
-->
@@ -24,12 +24,12 @@
<field eval="True" name="object"/>
</record>
<wizard
string="Requisition Request"
model="product.product"
name="product.product.procurement"
keyword="client_action_multi"
id="product_procurement_wizard"/>
<!-- <wizard-->
<!-- string="Requisition Request"-->
<!-- model="product.product"-->
<!-- name="product.product.procurement"-->
<!-- keyword="client_action_multi"-->
<!-- id="product_procurement_wizard"/>-->
</data>
</openerp>
+46
View File
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Compute Stock Minimum Rules Only -->
<record id="view_procurement_compute_wizard" model="ir.ui.view">
<field name="name">Compute Stock Minimum Rules Only</field>
<field name="model">mrp.procurement.orderpoint.compute</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Parameters">
<field name="automatic"/>
<separator colspan="4"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="procure_calculation" string="Compute Stock"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_procurement_compute" model="ir.actions.act_window">
<field name="name">Compute Stock Minimum Rules Only</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement.orderpoint.compute</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record model="ir.values" id="procurement_compute_order_point">
<field name="model_id" ref="mrp.model_mrp_procurement" />
<field name="object" eval="1" />
<field name="name">Compute Stock Minimum Rules Only</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_procurement_compute'))" />
<field name="key">action</field>
<field name="model">mrp.procurement</field>
</record>
</data>
</openerp>
+49
View File
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Compute Schedulers -->
<record id="view_compute_schedulers_wizard" model="ir.ui.view">
<field name="name">Compute Schedulers</field>
<field name="model">mrp.procurement.compute.all</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Scheduler Parameters">
<field name="automatic"/>
<separator colspan="4"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="procure_calculation" string="Compute Schedulers"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="action_compute_schedulers" model="ir.actions.act_window">
<field name="name">Compute Schedulers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.procurement.compute.all</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'record_id' : active_id}</field>
</record>
<record model="ir.values" id="compute_all_schedulers">
<field name="model_id" ref="mrp.model_mrp_procurement" />
<field name="object" eval="1" />
<field name="name">Compute Schedulers</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_compute_schedulers'))" />
<field name="key">action</field>
<field name="model">mrp.procurement</field>
</record>
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
<menuitem action="action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
</data>
</openerp>
+3 -3
View File
@@ -19,14 +19,14 @@
#
##############################################################################
import wizard_orderpoint_procurement
import make_procurement_product
import orderpoint_procurement
import schedulers_all
import wizard_procurement
import wizard_schedulers_all
import wizard_price
import wizard_workcenter_load
import wizard_track_prod
import wizard_change_production_qty
import make_procurement
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-102
View File
@@ -1,102 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import netsvc
import time
def _get_default(obj, cr, uid, data, context=None):
pool = pooler.get_pool(cr.dbname)
product = pool.get('product.product').browse(cr, uid, data['id'], context)
return {'product_id': product.id, 'uom_id':product.uom_id.id, 'qty':1.0}
def make_procurement(obj, cr, uid, data, context=None):
'''Create procurement'''
pool = pooler.get_pool(cr.dbname)
wh = pool.get('stock.warehouse').browse(cr, uid, data['form']['warehouse_id'], context)
user = pool.get('res.users').browse(cr, uid, uid, context)
procure_id = pool.get('mrp.procurement').create(cr, uid, {
'name':'INT:'+str(user.login),
'date_planned':data['form']['date_planned'],
'product_id':data['form']['product_id'],
'product_qty':data['form']['qty'],
'product_uom':data['form']['uom_id'],
'location_id':wh.lot_stock_id.id,
'procure_method':'make_to_order',
}, context=context)
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
return {}
class MakeProcurement(wizard.interface):
'''Wizard that create a procurement from a product form'''
done_form = """<?xml version="1.0"?>
<form string="Make Requisition">
<label string="Your procurement request has been sent !"/>
</form>"""
procurement_form = """<?xml version="1.0"?>
<form string="Internal Requisition Request">
<label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." align="0.0" colspan="4"/>
<field name="product_id"/>
<field name="warehouse_id"/>
<field name="qty"/>
<field name="uom_id"/>
<field name="date_planned"/>
</form>"""
procurement_fields = {
'qty': {'string': 'Quantity', 'type': 'float', 'digits':(16,2), 'required': True},
'product_id': {'string': 'product', 'type': 'many2one', 'relation': 'product.product', 'required': True, 'readonly':1},
'uom_id': {'string': 'Unit of Measure', 'type': 'many2one', 'relation': 'product.uom', 'required':True},
'warehouse_id': {'string': 'Warehouse', 'type': 'many2one', 'relation':'stock.warehouse', 'required':True},
'date_planned': {'string': 'Planned Date', 'type': 'date', 'required':True, 'default': lambda *args: time.strftime('%Y-%m-%d')}
}
states = {
'init': {
'actions': [_get_default],
'result': {'type': 'form', 'arch': procurement_form, 'fields': procurement_fields,
'state': [
('end', 'Cancel'),
('create', 'Ask New Products')
]
}
},
'done': {
'actions': [],
'result': {'type': 'form', 'arch': done_form, 'fields': {},
'state': [
('end', 'Close'),
]
}
},
'create': {
'actions': [],
'result': {'type': 'action', 'action': make_procurement, 'state': 'done'}
}
}
MakeProcurement('product.product.procurement')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pooler
import netsvc
from osv import fields, osv
import time
class make_procurement(osv.osv_memory):
'''Wizard that create a procurement from a product form'''
_name = 'make.procurement'
_description = 'Make Procurements'
def onchange_product_id(self, cr, uid, ids, prod_id):
product = self.pool.get('product.product').browse(cr, uid, prod_id)
return {'value': {'uom_id': product.uom_id.id}}
_columns = {
'qty': fields.float('Quantity', digits=(16,2), required=True),
'product_id': fields.many2one('product.product', 'Product', required=True, readonly=1),
'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'date_planned': fields.date('Planned Date', required=True),
}
_defaults = {
'date_planned': lambda *args: time.strftime('%Y-%m-%d'),
'qty': lambda *args: 1.0,
}
def make_procurement(self, cr, uid, ids, context=None):
'''Create procurement'''
for proc in self.browse(cr, uid, ids):
wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.warehouse_id.id, context)
user = self.pool.get('res.users').browse(cr, uid, uid, context)
procure_id = self.pool.get('mrp.procurement').create(cr, uid, {
'name':'INT:'+str(user.login),
'date_planned': proc.date_planned,
'product_id': proc.product_id.id,
'product_qty': proc.qty,
'product_uom': proc.uom_id.id,
'location_id': wh.lot_stock_id.id,
'procure_method':'make_to_order',
})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view')
id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
return {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'mrp.procurement',
'res_id' : procure_id,
'views': [(id3,'form'),(id2,'tree')],
'type': 'ir.actions.act_window',
}
def default_get(self, cr, uid, fields, context=None):
record_id = context and context.get('record_id', False) or False
res = super(make_procurement, self).default_get(cr, uid, fields, context=context)
if record_id:
product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id
res['product_id'] = product_id
return res
make_procurement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
#
# Order Point Method:
# - Order if the virtual stock of today is bellow the min of the defined order point
#
import threading
from osv import fields,osv
class procurement_compute(osv.osv_memory):
_name = 'mrp.procurement.orderpoint.compute'
_description = 'Automatic Order Point'
_columns = {
'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'),
}
_defaults = {
'automatic' : lambda *a: False,
}
def _procure_calculation_orderpoint(self, cr, uid, ids, context):
try:
proc_obj = self.pool.get('mrp.procurement')
for proc in self.browse(cr, uid, ids):
proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
finally:
cr.close()
return {}
def procure_calculation(self, cr, uid, ids, context):
threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context))
threaded_calculation.start()
return {}
procurement_compute()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+53
View File
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import threading
from osv import osv, fields
class procurement_compute(osv.osv_memory):
_name = 'mrp.procurement.compute.all'
_description = 'Compute all schedulers'
_columns = {
'automatic': fields.boolean('Automatic orderpoint',help='Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.'),
}
_defaults ={
'automatic': lambda *a: False,
}
def _procure_calculation_all(self, cr, uid, ids, context):
proc_obj = self.pool.get('mrp.procurement')
for proc in self.browse(cr, uid, ids):
proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\
context=context)
return {}
def procure_calculation(self, cr, uid, ids, context):
threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
threaded_calculation.start()
return {}
procurement_compute()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+84
View File
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
class stock_move_produce(osv.osv_memory):
_name = "stock.move.produce"
_description = "Produce"
_columns = {
'product_qty': fields.float('Quantity', required=True),
'mode': fields.selection([('consume_produce', 'Consumme & Produce'),
('consume', 'Consumme Only')], 'Mode', required=True)
}
def _get_product_qty(self, cr, uid, context):
prod = self.pool.get('mrp.production').browse(cr, uid,
context['active_id'], context=context)
done = 0.0
for move in prod.move_created_ids2:
done += move.product_qty
return (prod.product_qty - done) or prod.product_qty
_defaults = {
'product_qty': _get_product_qty,
'mode': lambda *x: 'consume'
}
def do_move_produce(self, cr, uid, ids, context={}):
datas = self.read(cr, uid, ids)[0]
prod_obj = self.pool.get('mrp.production')
# wf_service = netsvc.LocalService('workflow')
# wf_service.trg_validate(uid, 'mrp.production', context['active_id'],
# 'button_produce_done', cr)
prod_obj.action_production_end(cr, uid, [context['active_id']],
qty=datas['product_qty'], mode=datas['mode'])
return {}
stock_move_produce()
class change_production_qty(osv.osv_memory):
_name = "change.production.qty"
_description = "Change Production Qty"
_columns = {
'product_qty': fields.float('Quantity', required=True),
}
def _get_product_qty(self, cr, uid, context):
prod = self.pool.get('mrp.production').browse(cr, uid, context['active_id'], context=context)
return prod.product_qty
_defaults = {
'product_qty': _get_product_qty,
}
def change_prod_qty(self, cr, uid, ids, context={}):
datas = self.read(cr, uid, ids)[0]
prod_obj = self.pool.get('mrp.production')
prod_obj._change_prod_qty(cr, uid, context['active_ids'], datas['product_qty'], context=context)
return {}
change_production_qty()
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Produce -->
<record id="view_stock_move_produce_wizard" model="ir.ui.view">
<field name="name">Produce</field>
<field name="model">stock.move.produce</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Produce">
<separator string="Produce" colspan="4"/>
<field name="mode" colspan="4"/>
<field name="product_qty" colspan="2"/>
<newline/>
<separator string="" colspan="4" />
<label string="" colspan="2" />
<group col="2" colspan="1">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="do_move_produce" string="Confirm"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="move_produce" model="ir.actions.act_window">
<field name="name">Produce</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.move.produce</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="view_change_production_qty_wizard" model="ir.ui.view">
<field name="name">Change Production Qty</field>
<field name="model">change.production.qty</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Change Production Qty">
<separator string="Change Production Qty" colspan="4"/>
<field name="product_qty" colspan="2"/>
<separator string="" colspan="4" />
<label string="" colspan="2" />
<group col="2" colspan="1">
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="change_prod_qty" string="Validate"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
</field>
</record>
<record id="wizard_change_production_qty" model="ir.actions.act_window">
<field name="name">Change Production Qty</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">change.production.qty</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,73 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
#
# Order Point Method:
# - Order if the virtual stock of today is bellow the min of the defined order point
#
import wizard
import threading
import pooler
parameter_form = '''<?xml version="1.0"?>
<form string="Parameters" colspan="4">
<field name="automatic" />
</form>'''
parameter_fields = {
'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'If the stock of a product is under 0, it will act like an orderpoint', 'default': lambda *a: False},
}
def _procure_calculation_orderpoint(self, db_name, uid, data, context):
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
try:
proc_obj = pool.get('mrp.procurement')
automatic = data['form']['automatic']
proc_obj._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
use_new_cursor=cr.dbname, context=context)
finally:
cr.close()
return {}
def _procure_calculation(self, cr, uid, data, context):
threaded_calculation = threading.Thread(target=_procure_calculation_orderpoint, args=(self, cr.dbname, uid, data, context))
threaded_calculation.start()
return {}
class procurement_compute(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock')]}
},
'compute': {
'actions': [_procure_calculation],
'result': {'type': 'state', 'state':'end'}
},
}
procurement_compute('mrp.procurement.orderpoint.compute')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Some files were not shown because too many files have changed in this diff Show More