diff options
| author | rpa (Open ERP) <rpa@tinyerp.com> | 2010-03-11 12:16:33 +0530 |
|---|---|---|
| committer | rpa (Open ERP) <rpa@tinyerp.com> | 2010-03-11 12:16:33 +0530 |
| commit | f8fbe2e5dcb796dd3a5790bc1c3242379e02ffd8 (patch) | |
| tree | 514018dd7e7d5dac02fb07a46470a38a6fc1e284 | |
| parent | 53243af916e54a6d44ef7d1a42d8468b40b26254 (diff) | |
| parent | 223c30b38a4ff29114bd68e03a404bb88cc4a59e (diff) | |
[MERGE]: Merge with lp:~openerp-commiter/openobject-addons/osv-memory-wizards
bzr revid: rpa@tinyerp.com-20100311064633-67tfletn0zsw45yy
173 files changed, 5485 insertions, 3876 deletions
diff --git a/addons/account/__terp__.py b/addons/account/__terp__.py index 1c58efb161f..4a19883ac4b 100644 --- a/addons/account/__terp__.py +++ b/addons/account/__terp__.py @@ -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', diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index c82e0a7fd9a..78e7244996e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -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"> diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 3ef24386c2d..4723f2b890f 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -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)]" diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index ebfed02eb3c..7d6e3165e41 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -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"/> diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 7d6e7b1226d..96ac24e02cd 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -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: - diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py new file mode 100644 index 00000000000..fddb6bc0474 --- /dev/null +++ b/addons/account/wizard/account_chart.py @@ -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: + diff --git a/addons/account/wizard/account_chart_view.xml b/addons/account/wizard/account_chart_view.xml new file mode 100644 index 00000000000..ae89dfb9945 --- /dev/null +++ b/addons/account/wizard/account_chart_view.xml @@ -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> diff --git a/addons/account/wizard/account_fiscalyear_close_state.py b/addons/account/wizard/account_fiscalyear_close_state.py new file mode 100644 index 00000000000..8468bcf2635 --- /dev/null +++ b/addons/account/wizard/account_fiscalyear_close_state.py @@ -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: + diff --git a/addons/account/wizard/account_fiscalyear_close_state.xml b/addons/account/wizard/account_fiscalyear_close_state.xml new file mode 100644 index 00000000000..d6fe49c9b2c --- /dev/null +++ b/addons/account/wizard/account_fiscalyear_close_state.xml @@ -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> diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py new file mode 100644 index 00000000000..162d21a9654 --- /dev/null +++ b/addons/account/wizard/account_invoice_refund.py @@ -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: + diff --git a/addons/account/wizard/account_invoice_refund_view.xml b/addons/account/wizard/account_invoice_refund_view.xml new file mode 100644 index 00000000000..0d2bb036c06 --- /dev/null +++ b/addons/account/wizard/account_invoice_refund_view.xml @@ -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>
\ No newline at end of file diff --git a/addons/account/wizard/account_move_bank_reconcile.py b/addons/account/wizard/account_move_bank_reconcile.py new file mode 100644 index 00000000000..a39f500eac8 --- /dev/null +++ b/addons/account/wizard/account_move_bank_reconcile.py @@ -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: diff --git a/addons/account/wizard/account_move_bank_reconcile_view.xml b/addons/account/wizard/account_move_bank_reconcile_view.xml new file mode 100644 index 00000000000..5a542a7e270 --- /dev/null +++ b/addons/account/wizard/account_move_bank_reconcile_view.xml @@ -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> diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py new file mode 100644 index 00000000000..08aef8ca544 --- /dev/null +++ b/addons/account/wizard/account_move_journal.py @@ -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: + diff --git a/addons/account/wizard/account_move_journal_view.xml b/addons/account/wizard/account_move_journal_view.xml new file mode 100644 index 00000000000..e32148c9c69 --- /dev/null +++ b/addons/account/wizard/account_move_journal_view.xml @@ -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> diff --git a/addons/account/wizard/account_move_line_reconcile_select.py b/addons/account/wizard/account_move_line_reconcile_select.py new file mode 100644 index 00000000000..f1a72e44b91 --- /dev/null +++ b/addons/account/wizard/account_move_line_reconcile_select.py @@ -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: diff --git a/addons/account/wizard/account_move_line_reconcile_select_view.xml b/addons/account/wizard/account_move_line_reconcile_select_view.xml new file mode 100644 index 00000000000..2bb05b2e9ab --- /dev/null +++ b/addons/account/wizard/account_move_line_reconcile_select_view.xml @@ -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> diff --git a/addons/account/wizard/account_period_close.py b/addons/account/wizard/account_period_close.py new file mode 100644 index 00000000000..8ef38faf3cc --- /dev/null +++ b/addons/account/wizard/account_period_close.py @@ -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: + diff --git a/addons/account/wizard/account_period_close_view.xml b/addons/account/wizard/account_period_close_view.xml new file mode 100644 index 00000000000..fc8c5273a79 --- /dev/null +++ b/addons/account/wizard/account_period_close_view.xml @@ -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>
\ No newline at end of file diff --git a/addons/account/wizard/wizard_account_chart.py b/addons/account/wizard/wizard_account_chart.py deleted file mode 100644 index ca8153f3ce7..00000000000 --- a/addons/account/wizard/wizard_account_chart.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_bank_reconcile.py b/addons/account/wizard/wizard_bank_reconcile.py deleted file mode 100644 index c081657304a..00000000000 --- a/addons/account/wizard/wizard_bank_reconcile.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_fiscalyear_close_state.py b/addons/account/wizard/wizard_fiscalyear_close_state.py deleted file mode 100644 index 2f8331f2d3e..00000000000 --- a/addons/account/wizard/wizard_fiscalyear_close_state.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_journal.py b/addons/account/wizard/wizard_journal.py deleted file mode 100644 index fd2b012863e..00000000000 --- a/addons/account/wizard/wizard_journal.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_period_close.py b/addons/account/wizard/wizard_period_close.py deleted file mode 100644 index d6ba73683f2..00000000000 --- a/addons/account/wizard/wizard_period_close.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_reconcile.py b/addons/account/wizard/wizard_reconcile.py index 9debe7afbef..6d7de403f79 100644 --- a/addons/account/wizard/wizard_reconcile.py +++ b/addons/account/wizard/wizard_reconcile.py @@ -19,13 +19,13 @@ # ############################################################################## -import wizard +from datetime import datetime +from tools.translate import _ import netsvc -import time import osv import pooler -from datetime import datetime -from tools.translate import _ +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'} } } diff --git a/addons/account/wizard/wizard_reconcile_select.py b/addons/account/wizard/wizard_reconcile_select.py deleted file mode 100644 index 594020debd4..00000000000 --- a/addons/account/wizard/wizard_reconcile_select.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_refund.py b/addons/account/wizard/wizard_refund.py deleted file mode 100644 index 42526f3cc0a..00000000000 --- a/addons/account/wizard/wizard_refund.py +++ /dev/null @@ -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: - diff --git a/addons/account/wizard/wizard_state_open.py b/addons/account/wizard/wizard_state_open.py index 9720f48e25e..f33c90231f4 100644 --- a/addons/account/wizard/wizard_state_open.py +++ b/addons/account/wizard/wizard_state_open.py @@ -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], diff --git a/addons/account_voucher/__terp__.py b/addons/account_voucher/__terp__.py index b6843372f4c..01874eeed77 100755 --- a/addons/account_voucher/__terp__.py +++ b/addons/account_voucher/__terp__.py @@ -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', diff --git a/addons/account_voucher/wizard/__init__.py b/addons/account_voucher/wizard/__init__.py index 136fd1d8ee9..237055f710d 100644 --- a/addons/account_voucher/wizard/__init__.py +++ b/addons/account_voucher/wizard/__init__.py @@ -19,4 +19,5 @@ # ############################################################################## -import open_voucher + +import account_voucher_open diff --git a/addons/account_voucher/wizard/account_voucher_open.py b/addons/account_voucher/wizard/account_voucher_open.py new file mode 100644 index 00000000000..508a2d1c275 --- /dev/null +++ b/addons/account_voucher/wizard/account_voucher_open.py @@ -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() + + diff --git a/addons/account_voucher/wizard/account_voucher_open_view.xml b/addons/account_voucher/wizard/account_voucher_open_view.xml new file mode 100644 index 00000000000..5e71b20c6f4 --- /dev/null +++ b/addons/account_voucher/wizard/account_voucher_open_view.xml @@ -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>
\ No newline at end of file diff --git a/addons/account_voucher/wizard/open_voucher.py b/addons/account_voucher/wizard/open_voucher.py deleted file mode 100644 index 5a3892e1a14..00000000000 --- a/addons/account_voucher/wizard/open_voucher.py +++ /dev/null @@ -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: diff --git a/addons/auction/__terp__.py b/addons/auction/__terp__.py index 83064640266..c3f9058f070 100644 --- a/addons/auction/__terp__.py +++ b/addons/auction/__terp__.py @@ -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' diff --git a/addons/auction/auction.py b/addons/auction/auction.py index 0ece4690d9f..979f2c6cf42 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -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): diff --git a/addons/auction/auction_view.xml b/addons/auction/auction_view.xml index 2189253f3ce..ee1004ab0f3 100644 --- a/addons/auction/auction_view.xml +++ b/addons/auction/auction_view.xml @@ -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> diff --git a/addons/auction/auction_wizard.xml b/addons/auction/auction_wizard.xml index 0a93799cc20..ab1b051add5 100644 --- a/addons/auction/auction_wizard.xml +++ b/addons/auction/auction_wizard.xml @@ -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> diff --git a/addons/auction/wizard/__init__.py b/addons/auction/wizard/__init__.py index ec07ef6e04f..b82dcda5307 100644 --- a/addons/auction/wizard/__init__.py +++ b/addons/auction/wizard/__init__.py @@ -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: diff --git a/addons/auction/wizard/auction_lots_able.py b/addons/auction/wizard/auction_lots_able.py new file mode 100644 index 00000000000..686d26c0341 --- /dev/null +++ b/addons/auction/wizard/auction_lots_able.py @@ -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() diff --git a/addons/auction/wizard/auction_lots_able_view.xml b/addons/auction/wizard/auction_lots_able_view.xml new file mode 100644 index 00000000000..374390a1404 --- /dev/null +++ b/addons/auction/wizard/auction_lots_able_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_lots_auction_move.py b/addons/auction/wizard/auction_lots_auction_move.py new file mode 100644 index 00000000000..71e2b16e8e0 --- /dev/null +++ b/addons/auction/wizard/auction_lots_auction_move.py @@ -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: + diff --git a/addons/auction/wizard/auction_lots_auction_move_view.xml b/addons/auction/wizard/auction_lots_auction_move_view.xml new file mode 100644 index 00000000000..394a916c96c --- /dev/null +++ b/addons/auction/wizard/auction_lots_auction_move_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_lots_enable.py b/addons/auction/wizard/auction_lots_enable.py new file mode 100644 index 00000000000..9d75ef1a589 --- /dev/null +++ b/addons/auction/wizard/auction_lots_enable.py @@ -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() diff --git a/addons/auction/wizard/auction_lots_enable_view.xml b/addons/auction/wizard/auction_lots_enable_view.xml new file mode 100644 index 00000000000..e6a6936c5eb --- /dev/null +++ b/addons/auction/wizard/auction_lots_enable_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_lots_make_invoice.py b/addons/auction/wizard/auction_lots_make_invoice.py new file mode 100644 index 00000000000..50177f54203 --- /dev/null +++ b/addons/auction/wizard/auction_lots_make_invoice.py @@ -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() diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer.py b/addons/auction/wizard/auction_lots_make_invoice_buyer.py new file mode 100644 index 00000000000..b35dc072776 --- /dev/null +++ b/addons/auction/wizard/auction_lots_make_invoice_buyer.py @@ -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() diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml b/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml new file mode 100644 index 00000000000..b45d5bdbb1c --- /dev/null +++ b/addons/auction/wizard/auction_lots_make_invoice_buyer_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_lots_make_invoice_view.xml b/addons/auction/wizard/auction_lots_make_invoice_view.xml new file mode 100644 index 00000000000..e629942c5d5 --- /dev/null +++ b/addons/auction/wizard/auction_lots_make_invoice_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_lots_sms_send.py b/addons/auction/wizard/auction_lots_sms_send.py new file mode 100644 index 00000000000..95351c6965a --- /dev/null +++ b/addons/auction/wizard/auction_lots_sms_send.py @@ -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: + diff --git a/addons/auction/wizard/auction_lots_sms_send_view.xml b/addons/auction/wizard/auction_lots_sms_send_view.xml new file mode 100644 index 00000000000..7e57833f72d --- /dev/null +++ b/addons/auction/wizard/auction_lots_sms_send_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_pay_buy.py b/addons/auction/wizard/auction_pay_buy.py new file mode 100644 index 00000000000..8e7136b0064 --- /dev/null +++ b/addons/auction/wizard/auction_pay_buy.py @@ -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: + diff --git a/addons/auction/wizard/auction_pay_buy_view.xml b/addons/auction/wizard/auction_pay_buy_view.xml new file mode 100644 index 00000000000..daa0ea2a195 --- /dev/null +++ b/addons/auction/wizard/auction_pay_buy_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_pay_sel.py b/addons/auction/wizard/auction_pay_sel.py new file mode 100644 index 00000000000..2643a565e3e --- /dev/null +++ b/addons/auction/wizard/auction_pay_sel.py @@ -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() diff --git a/addons/auction/wizard/auction_pay_sel_view.xml b/addons/auction/wizard/auction_pay_sel_view.xml new file mode 100644 index 00000000000..b96f25032ac --- /dev/null +++ b/addons/auction/wizard/auction_pay_sel_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_wizard_enable_taken.py b/addons/auction/wizard/auction_payer_sel.py index 01f54ca28dc..b59cbf591cc 100644 --- a/addons/auction/wizard/auction_wizard_enable_taken.py +++ b/addons/auction/wizard/auction_payer_sel.py @@ -19,43 +19,42 @@ # ############################################################################## -import wizard +from osv import fields, osv +from tools.translate import _ import netsvc import pooler -#field name="confirm_en"/> - -take_form = """<?xml version="1.0"?> -<form title="Confirm"> - <separator string="Confirmation enable taken away" colspan="4"/> - <newline/> -</form> -""" - -take_fields = { - 'confirm_en': {'string':'Catalog Number', 'type':'integer'}, -} +import time +import tools +import wizard -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 auction_payer(osv.osv_memory): -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: diff --git a/addons/auction/wizard/auction_payer_sel_view.xml b/addons/auction/wizard/auction_payer_sel_view.xml new file mode 100644 index 00000000000..93fe0ef38b1 --- /dev/null +++ b/addons/auction/wizard/auction_payer_sel_view.xml @@ -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> diff --git a/addons/auction/wizard/auction_taken.py b/addons/auction/wizard/auction_taken.py new file mode 100644 index 00000000000..48a5d8cf6af --- /dev/null +++ b/addons/auction/wizard/auction_taken.py @@ -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('&','&').replace('<','<').replace('>','>') + + 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() diff --git a/addons/auction/wizard/auction_taken_view.xml b/addons/auction/wizard/auction_taken_view.xml new file mode 100644 index 00000000000..8ed7f730427 --- /dev/null +++ b/addons/auction/wizard/auction_taken_view.xml @@ -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> diff --git a/addons/auction/wizard/wizard_auction_invoice_buyer.py b/addons/auction/wizard/wizard_auction_invoice_buyer.py deleted file mode 100644 index 6cf12b5da22..00000000000 --- a/addons/auction/wizard/wizard_auction_invoice_buyer.py +++ /dev/null @@ -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: - diff --git a/addons/auction/wizard/wizard_auction_journal.py b/addons/auction/wizard/wizard_auction_journal.py deleted file mode 100644 index 79329592165..00000000000 --- a/addons/auction/wizard/wizard_auction_journal.py +++ /dev/null @@ -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: - diff --git a/addons/auction/wizard/wizard_emporte.py b/addons/auction/wizard/wizard_emporte.py deleted file mode 100644 index 1172404e218..00000000000 --- a/addons/auction/wizard/wizard_emporte.py +++ /dev/null @@ -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('&','&').replace('<','<').replace('>','>') - -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: - diff --git a/addons/auction/wizard/wizard_lot_date_move.py b/addons/auction/wizard/wizard_lot_date_move.py deleted file mode 100644 index e6e13ea0ab2..00000000000 --- a/addons/auction/wizard/wizard_lot_date_move.py +++ /dev/null @@ -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: - diff --git a/addons/auction/wizard/wizard_lots_pay.py b/addons/auction/wizard/wizard_lots_pay.py deleted file mode 100644 index a6b8f635ba4..00000000000 --- a/addons/auction/wizard/wizard_lots_pay.py +++ /dev/null @@ -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: - diff --git a/addons/auction/wizard/wizard_lots_sms.py b/addons/auction/wizard/wizard_lots_sms.py deleted file mode 100644 index dc60a9bd24d..00000000000 --- a/addons/auction/wizard/wizard_lots_sms.py +++ /dev/null @@ -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: - diff --git a/addons/auction/wizard/wizard_pay.py b/addons/auction/wizard/wizard_pay.py deleted file mode 100644 index ff68c2b5b8d..00000000000 --- a/addons/auction/wizard/wizard_pay.py +++ /dev/null @@ -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: - diff --git a/addons/auction/wizard/wizard_payer.py b/addons/auction/wizard/wizard_payer.py deleted file mode 100644 index 6e224fbadad..00000000000 --- a/addons/auction/wizard/wizard_payer.py +++ /dev/null @@ -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: - diff --git a/addons/audittrail/__terp__.py b/addons/audittrail/__terp__.py index e7ecd839efb..8718523e7f1 100644 --- a/addons/audittrail/__terp__.py +++ b/addons/audittrail/__terp__.py @@ -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' diff --git a/addons/audittrail/audittrail_view.xml b/addons/audittrail/audittrail_view.xml index 98a4ecc00e9..536ca78741e 100644 --- a/addons/audittrail/audittrail_view.xml +++ b/addons/audittrail/audittrail_view.xml @@ -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> diff --git a/addons/audittrail/wizard/__init__.py b/addons/audittrail/wizard/__init__.py index c7b5a20d884..9b2af466a01 100644 --- a/addons/audittrail/wizard/__init__.py +++ b/addons/audittrail/wizard/__init__.py @@ -19,6 +19,6 @@ # ############################################################################## -import wizard_view_log +import audittrail_view_log # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/audittrail/wizard/audittrail_view_log.py b/addons/audittrail/wizard/audittrail_view_log.py new file mode 100644 index 00000000000..2e170f27200 --- /dev/null +++ b/addons/audittrail/wizard/audittrail_view_log.py @@ -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: + diff --git a/addons/audittrail/wizard/audittrail_view_log_view.xml b/addons/audittrail/wizard/audittrail_view_log_view.xml new file mode 100644 index 00000000000..87648c7e136 --- /dev/null +++ b/addons/audittrail/wizard/audittrail_view_log_view.xml @@ -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> diff --git a/addons/audittrail/wizard/wizard_view_log.py b/addons/audittrail/wizard/wizard_view_log.py deleted file mode 100644 index 81936bcd54c..00000000000 --- a/addons/audittrail/wizard/wizard_view_log.py +++ /dev/null @@ -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: - diff --git a/addons/base_calendar/__terp__.py b/addons/base_calendar/__terp__.py index e433fbb7668..ce65e1166c5 100644 --- a/addons/base_calendar/__terp__.py +++ b/addons/base_calendar/__terp__.py @@ -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, diff --git a/addons/base_calendar/wizard/__init__.py b/addons/base_calendar/wizard/__init__.py index 60c61475131..38f790bcd42 100644 --- a/addons/base_calendar/wizard/__init__.py +++ b/addons/base_calendar/wizard/__init__.py @@ -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: diff --git a/addons/base_calendar/wizard/calendar_event_edit_all.py b/addons/base_calendar/wizard/calendar_event_edit_all.py new file mode 100644 index 00000000000..0a7fddadb2a --- /dev/null +++ b/addons/base_calendar/wizard/calendar_event_edit_all.py @@ -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: diff --git a/addons/base_calendar/wizard/calendar_event_edit_all_view.xml b/addons/base_calendar/wizard/calendar_event_edit_all_view.xml new file mode 100644 index 00000000000..15bd025441a --- /dev/null +++ b/addons/base_calendar/wizard/calendar_event_edit_all_view.xml @@ -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> diff --git a/addons/base_calendar/wizard/wizard_cal_edit_event.py b/addons/base_calendar/wizard/wizard_cal_edit_event.py deleted file mode 100644 index 8c2da2314c5..00000000000 --- a/addons/base_calendar/wizard/wizard_cal_edit_event.py +++ /dev/null @@ -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: diff --git a/addons/base_report_creator/__terp__.py b/addons/base_report_creator/__terp__.py index 5a78a903a5c..bee7ec57c91 100644 --- a/addons/base_report_creator/__terp__.py +++ b/addons/base_report_creator/__terp__.py @@ -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' ], diff --git a/addons/base_report_creator/base_report_creator_view.xml b/addons/base_report_creator/base_report_creator_view.xml index 30c6b3735a9..1d606b93ec4 100644 --- a/addons/base_report_creator/base_report_creator_view.xml +++ b/addons/base_report_creator/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"/> diff --git a/addons/base_report_creator/base_report_creator_wizard.xml b/addons/base_report_creator/base_report_creator_wizard.xml index eb956e89c6d..a8dad6f9b41 100644 --- a/addons/base_report_creator/base_report_creator_wizard.xml +++ b/addons/base_report_creator/base_report_creator_wizard.xml @@ -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> diff --git a/addons/base_report_creator/wizard/__init__.py b/addons/base_report_creator/wizard/__init__.py index 8fd4dff283a..945d42586d1 100644 --- a/addons/base_report_creator/wizard/__init__.py +++ b/addons/base_report_creator/wizard/__init__.py @@ -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: diff --git a/addons/base_report_creator/wizard/report_menu_create.py b/addons/base_report_creator/wizard/report_menu_create.py index 5d3cc322a7f..38821a81797 100644 --- a/addons/base_report_creator/wizard/report_menu_create.py +++ b/addons/base_report_creator/wizard/report_menu_create.py @@ -20,62 +20,55 @@ ############################################################################## +from osv import fields, osv +from tools.translate import _ +import netsvc +import pooler import time +import tools import wizard -import osv -import pooler - -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: diff --git a/addons/base_report_creator/wizard/report_menu_create_view.xml b/addons/base_report_creator/wizard/report_menu_create_view.xml new file mode 100644 index 00000000000..dd8ecb441c4 --- /dev/null +++ b/addons/base_report_creator/wizard/report_menu_create_view.xml @@ -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>
\ No newline at end of file diff --git a/addons/crm/__terp__.py b/addons/crm/__terp__.py index 7f6d8c75aaf..96cdfa0b8f3 100644 --- a/addons/crm/__terp__.py +++ b/addons/crm/__terp__.py @@ -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', diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index a1f1cef502e..59bedbb3b6a 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -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> diff --git a/addons/crm/crm_meeting_wizard.xml b/addons/crm/crm_meeting_wizard.xml deleted file mode 100644 index 8d6b66b3f2d..00000000000 --- a/addons/crm/crm_meeting_wizard.xml +++ /dev/null @@ -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> diff --git a/addons/mrp/__init__.py b/addons/mrp/__init__.py index b219d932141..ca3dfa07ac9 100644 --- a/addons/mrp/__init__.py +++ b/addons/mrp/__init__.py @@ -26,4 +26,6 @@ import wizard import report import company import schedulers + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py index a147266ce1d..dbd96f6c98e 100644 --- a/addons/mrp/__terp__.py +++ b/addons/mrp/__terp__.py @@ -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, diff --git a/addons/mrp/make_procurement.xml b/addons/mrp/make_procurement.xml new file mode 100644 index 00000000000..fae3eab6f42 --- /dev/null +++ b/addons/mrp/make_procurement.xml @@ -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>
\ No newline at end of file diff --git a/addons/mrp/mrp_wizard.xml b/addons/mrp/mrp_wizard.xml index 74001494c77..41d945f61a1 100644 --- a/addons/mrp/mrp_wizard.xml +++ b/addons/mrp/mrp_wizard.xml @@ -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> diff --git a/addons/mrp/orderpoint_procurement.xml b/addons/mrp/orderpoint_procurement.xml new file mode 100644 index 00000000000..3a2ac2bb638 --- /dev/null +++ b/addons/mrp/orderpoint_procurement.xml @@ -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>
\ No newline at end of file diff --git a/addons/mrp/schedulers_all.xml b/addons/mrp/schedulers_all.xml new file mode 100644 index 00000000000..84d6be3cbd4 --- /dev/null +++ b/addons/mrp/schedulers_all.xml @@ -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>
\ No newline at end of file diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py index 240f25daa9d..57b1dee1a7c 100644 --- a/addons/mrp/wizard/__init__.py +++ b/addons/mrp/wizard/__init__.py @@ -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: diff --git a/addons/mrp/wizard/make_procurement.py b/addons/mrp/wizard/make_procurement.py deleted file mode 100644 index 0cf12107181..00000000000 --- a/addons/mrp/wizard/make_procurement.py +++ /dev/null @@ -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: - diff --git a/addons/mrp/wizard/make_procurement_product.py b/addons/mrp/wizard/make_procurement_product.py new file mode 100644 index 00000000000..3ef342c308d --- /dev/null +++ b/addons/mrp/wizard/make_procurement_product.py @@ -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: + diff --git a/addons/mrp/wizard/orderpoint_procurement.py b/addons/mrp/wizard/orderpoint_procurement.py new file mode 100644 index 00000000000..bfa67f337f1 --- /dev/null +++ b/addons/mrp/wizard/orderpoint_procurement.py @@ -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: + diff --git a/addons/mrp/wizard/schedulers_all.py b/addons/mrp/wizard/schedulers_all.py new file mode 100644 index 00000000000..6e8dca9d636 --- /dev/null +++ b/addons/mrp/wizard/schedulers_all.py @@ -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: + diff --git a/addons/mrp/wizard/wizard_mrp.py b/addons/mrp/wizard/wizard_mrp.py new file mode 100644 index 00000000000..fefca3ae6e4 --- /dev/null +++ b/addons/mrp/wizard/wizard_mrp.py @@ -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() diff --git a/addons/mrp/wizard/wizard_mrp.xml b/addons/mrp/wizard/wizard_mrp.xml new file mode 100644 index 00000000000..7c93245a3d8 --- /dev/null +++ b/addons/mrp/wizard/wizard_mrp.xml @@ -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>
\ No newline at end of file diff --git a/addons/mrp/wizard/wizard_orderpoint_procurement.py b/addons/mrp/wizard/wizard_orderpoint_procurement.py deleted file mode 100644 index a4fa57bb9a8..00000000000 --- a/addons/mrp/wizard/wizard_orderpoint_procurement.py +++ /dev/null @@ -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: - diff --git a/addons/mrp/wizard/wizard_schedulers_all.py b/addons/mrp/wizard/wizard_schedulers_all.py deleted file mode 100644 index e93e31c0599..00000000000 --- a/addons/mrp/wizard/wizard_schedulers_all.py +++ /dev/null @@ -1,64 +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 threading -import pooler - -parameter_form = '''<?xml version="1.0"?> -<form string="Scheduler Parameters" colspan="4"> - <field name="automatic" /> -</form>''' - -parameter_fields = { - 'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', '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.', 'default': lambda *a: False}, -} - -def _procure_calculation_all(self, db_name, uid, data, context): - db, pool = pooler.get_db_and_pool(db_name) - cr = db.cursor() - proc_obj = pool.get('mrp.procurement') - automatic = data['form']['automatic'] - proc_obj.run_scheduler(cr, uid, automatic=automatic, use_new_cursor=cr.dbname,\ - context=context) - cr.close() - return {} - -def _procure_calculation(self, cr, uid, data, context): - threaded_calculation = threading.Thread(target=_procure_calculation_all, 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.compute.all') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/mrp_repair/__terp__.py b/addons/mrp_repair/__terp__.py index 2f44e257a80..0cb90558a0c 100644 --- a/addons/mrp_repair/__terp__.py +++ b/addons/mrp_repair/__terp__.py @@ -39,9 +39,11 @@ 'security/ir.model.access.csv', 'mrp_repair_sequence.xml', 'mrp_repair_wizard.xml', + 'mrp_repair_cancel_view.xml', + 'mrp_repair_make_invoice_view.xml', 'mrp_repair_view.xml', 'mrp_repair_workflow.xml', - 'mrp_repair_report.xml' + 'mrp_repair_report.xml', ], 'demo_xml': [], 'installable': True, diff --git a/addons/mrp_repair/mrp_repair_cancel_view.xml b/addons/mrp_repair/mrp_repair_cancel_view.xml new file mode 100644 index 00000000000..6e900939fd6 --- /dev/null +++ b/addons/mrp_repair/mrp_repair_cancel_view.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <!-- Cancel Repair --> + + <record id="view_cancel_repair" model="ir.ui.view"> + <field name="name">Cancel Repair</field> + <field name="model">mrp.repair.cancel</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Requisition Request"> + <label string="This operation will cancel the Repair process, but will not cancel it's Invoice. Do you want to continue?" colspan="4"/> + <newline/> + <group col="2" colspan="4"> + <button icon='gtk-cancel' special="cancel" + string="No" /> + <button name="cancel_repair" string="Yes" + colspan="1" type="object" icon="gtk-ok" /> + </group> + </form> + </field> + </record> + + <record id="action_cancel_repair" model="ir.actions.act_window"> + <field name="name">Cancel Repair</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">mrp.repair.cancel</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="action_cancel_repair_related"> + <field name="model_id" ref="mrp_repair.model_mrp_repair" /> + <field name="object" eval="1" /> + <field name="name">Cancel Repair</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_cancel_repair'))" /> + <field name="key">action</field> + <field name="model">mrp.repair</field> + </record> + + </data> +</openerp> diff --git a/addons/mrp_repair/mrp_repair_make_invoice_view.xml b/addons/mrp_repair/mrp_repair_make_invoice_view.xml new file mode 100644 index 00000000000..6d489e5704b --- /dev/null +++ b/addons/mrp_repair/mrp_repair_make_invoice_view.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <!-- Make Invoice --> + + <record id="view_make_invoice" model="ir.ui.view"> + <field name="name">Make Invoice</field> + <field name="model">mrp.repair.make_invoice</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create invoices"> + <separator colspan="4" string="Do you really want to create the invoices ?" /> + <field name="group"/> + <newline/> + <group col="2" colspan="4"> + <button icon='gtk-cancel' special="cancel" + string="Cancel" /> + <button name="make_invoices" string="Create Invoice" + colspan="1" type="object" icon="gtk-ok" /> + </group> + </form> + </field> + </record> + + <record id="action_make_invoice" model="ir.actions.act_window"> + <field name="name">Make Invoice</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">mrp.repair.make_invoice</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="context">{'active_ids' : active_ids}</field> + </record> + + <record model="ir.values" id="action_make_invoice_related"> + <field name="object" eval="1" /> + <field name="name">Make Invoice</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_make_invoice'))" /> + <field name="key2">client_action_multi</field> + <field name="key">action</field> + <field name="model">mrp.repair</field> + </record> + + </data> +</openerp> diff --git a/addons/mrp_repair/mrp_repair_wizard.xml b/addons/mrp_repair/mrp_repair_wizard.xml index 42383f517cc..b0b2c89d50d 100644 --- a/addons/mrp_repair/mrp_repair_wizard.xml +++ b/addons/mrp_repair/mrp_repair_wizard.xml @@ -1,21 +1,22 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data> - <wizard - id="action_cancel_repair" - model="mrp.repair" - name="mrp.repair.cancel" - string="Cancel Repair" - menu = "False" - multi = "True" - /> - <wizard - id="wizard_mrp_repair_make_invoice" - keyword="client_action_multi" - model="mrp.repair" - name="mrp.repair.make_invoice" - multi="True" - string="Make invoices"/> +<!-- <wizard --> +<!-- id="action_cancel_repair" --> +<!-- model="mrp.repair" --> +<!-- name="mrp.repair.cancel"--> +<!-- string="Cancel Repair"--> +<!-- menu = "False"--> +<!-- multi = "True"--> +<!-- />--> + +<!-- <wizard--> +<!-- id="wizard_mrp_repair_make_invoice"--> +<!-- keyword="client_action_multi"--> +<!-- model="mrp.repair"--> +<!-- name="mrp.repair.make_invoice"--> +<!-- multi="True"--> +<!-- string="Make invoices"/>--> </data> </openerp> diff --git a/addons/mrp_repair/wizard/__init__.py b/addons/mrp_repair/wizard/__init__.py index ec3063f01de..4f3075f055c 100644 --- a/addons/mrp_repair/wizard/__init__.py +++ b/addons/mrp_repair/wizard/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import wizard_cancel_repair -import wizard_make_invoice +import cancel_repair +import make_invoice # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp_repair/wizard/cancel_repair.py b/addons/mrp_repair/wizard/cancel_repair.py new file mode 100644 index 00000000000..423be2e27b3 --- /dev/null +++ b/addons/mrp_repair/wizard/cancel_repair.py @@ -0,0 +1,63 @@ +# -*- 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 netsvc +from osv import osv,fields +from tools.translate import _ + +class repair_cancel(osv.osv_memory): + _name = 'mrp.repair.cancel' + _description = 'Cancel Repair' + + def cancel_repair(self, cr, uid, ids, context): + record_id = context and context.get('record_id', False) or False + if record_id: + repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id]) + + if repair_obj[0].invoiced or repair_obj[0].invoice_method == 'none': + self.pool.get('mrp.repair').write(cr, uid, record_id, {'state':'cancel'}) + mrp_line_obj = self.pool.get('mrp.repair.line') + for line in repair_obj: + mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'}) + else: + raise osv.except_osv(_('Warning!'),_('Repair is not cancelled. It is not invoiced.')) + + return {} + + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + record_id = context and context.get('record_id', False) or False + res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) + if record_id: + repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])[0] + if not repair_obj.invoice_id: + res['arch'] = """ <form string="Cancel Repair" colspan="4"> + <group col="2" colspan="2"> + <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/> + <button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/> + </group> + </form> + """ + return res + +repair_cancel() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/auction/wizard/auction_wizard_able_taken.py b/addons/mrp_repair/wizard/make_invoice.py index 261cc47c48b..983ebabac25 100644 --- a/addons/auction/wizard/auction_wizard_able_taken.py +++ b/addons/mrp_repair/wizard/make_invoice.py @@ -19,43 +19,34 @@ # ############################################################################## -import wizard import netsvc -import pooler -take_form = """<?xml version="1.0"?> -<form title="Confirm"> - <separator string="Confirmation set taken away" colspan="4"/> - <newline/> -</form> -""" +from osv import osv, fields -take_fields = { -# 'confirm_en': {'string':'Catalog Number', 'type':'integer'}, -} +class make_invoice(osv.osv_memory): + _name = 'mrp.repair.make_invoice' + _description = 'Make Invoice' + + _columns = { + 'group': fields.boolean('Group by partner invoice address'), + } -def _confirm_able(self,cr,uid,data,context={}): - res={} - pool = pooler.get_pool(cr.dbname) - pool.get('auction.lots').write(cr,uid,data['ids'],{'ach_emp':True}) - return {} - -class able_take_away(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : { - 'type' : 'form', - 'arch' : take_form, - 'fields' : take_fields, - 'state' : [('end', 'Cancel'),('go', 'Able Taken away')]} - }, - 'go' : { - 'actions' : [_confirm_able], - 'result' : {'type' : 'state', 'state' : 'end'} - }, -} -able_take_away('auction.lots.able') + def make_invoices(self, cr, uid, ids, context): + inv = self.browse(cr, uid, ids[0]) + order_obj = self.pool.get('mrp.repair') + newinv = order_obj.action_invoice_create(cr, uid, context['active_ids'], group=inv.group,context=context) + + return { + 'domain': [('id','in', newinv.values())], + 'name': 'Invoices', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'account.invoice', + 'view_id': False, + 'context': "{'type':'out_invoice'}", + 'type': 'ir.actions.act_window' + } +make_invoice() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp_repair/wizard/wizard_cancel_repair.py b/addons/mrp_repair/wizard/wizard_cancel_repair.py deleted file mode 100644 index d895096ce6f..00000000000 --- a/addons/mrp_repair/wizard/wizard_cancel_repair.py +++ /dev/null @@ -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 netsvc -import pooler - -cancel_form = """<?xml version="1.0"?> -<form string="Cancel Repair...??"> - <label colspan="4" string="This operation will cancel the Repair process, but will not cancel it's Invoice.\nDo you want to continue?" /> -</form> -""" - -cancel_fields = {} - -def check_state(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0] - if repair_obj.invoice_id: - return 'display' - else: - pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'}) - return 'end' - - -def _cancel_repair(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids']) - pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'}) - mrp_line_obj = pool.get('mrp.repair.line') - for line in repair_obj: - mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'}) - return {} - -class repair_cancel(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'choice', 'next_state' : check_state} - }, - - 'display' : { - 'actions' : [], - 'result' : {'type' : 'form', - 'arch' : cancel_form, - 'fields' : cancel_fields, - 'state' : [('end', 'No'),('yes', 'Yes') ]} - }, - 'yes' : { - 'actions' : [], - 'result' : {'type' : 'action', - 'action' : _cancel_repair, - 'state' : 'end'} - }, - 'end' : { - 'actions' : [], - 'result': {'type': 'state', 'state': 'end'}, - }, - } -repair_cancel("mrp.repair.cancel") - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/mrp_repair/wizard/wizard_make_invoice.py b/addons/mrp_repair/wizard/wizard_make_invoice.py deleted file mode 100644 index 71aefadfe4b..00000000000 --- a/addons/mrp_repair/wizard/wizard_make_invoice.py +++ /dev/null @@ -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 netsvc -import pooler - -invoice_form = """<?xml version="1.0"?> -<form string="Create invoices"> - <separator colspan="4" string="Do you really want to create the invoices ?" /> - <field name="group"/> -</form> -""" -invoice_fields = { - 'group': { - 'string': 'Group by partner invoice address', - 'type':'boolean' - }, -} - -ack_form = """<?xml version="1.0"?> -<form string="Create invoices"> - <separator string="Invoices created" /> -</form>""" - -ack_fields = {} - -def _makeInvoices(self, cr, uid, data, context): - order_obj = pooler.get_pool(cr.dbname).get('mrp.repair') - newinv = order_obj.action_invoice_create(cr, uid, data['ids'],group=data['form']['group'],context=context) - - return { - 'domain': [('id','in', newinv.values())], - 'name': 'Invoices', - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'account.invoice', - 'view_id': False, - 'context': "{'type':'out_refund'}", - 'type': 'ir.actions.act_window' - } - - -class make_invoice(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'form', - 'arch' : invoice_form, - 'fields' : invoice_fields, - 'state' : [('end', 'Cancel'),('invoice', 'Create invoices') ]} - }, - 'invoice' : { - 'actions' : [], - 'result' : {'type' : 'action', - 'action' : _makeInvoices, - 'state' : 'end'} - }, - } -make_invoice("mrp.repair.make_invoice") - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/product/__terp__.py b/addons/product/__terp__.py index 4128e992c82..ef8dd5de345 100644 --- a/addons/product/__terp__.py +++ b/addons/product/__terp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -51,6 +51,7 @@ 'security/ir.model.access.csv', 'product_data.xml', 'product_report.xml', + 'wizard/product_price_list_view.xml', 'product_view.xml', 'pricelist_view.xml', 'partner_view.xml', diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index e6c5588f4f7..6272645f907 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -602,6 +602,15 @@ <field name="view_id" ref="product_template_tree_view"/> </record> + <record model="ir.values" id="action_wizard_pricelist_report"> + <field name="object" eval="1" /> + <field name="name">Price List</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_product_price_view'))" /> + <field name="key">action</field> + <field name="model">product.product</field> + </record> + <!-- <menuitem action="product_template_action_tree" id="menu_templates" parent="product.menu_products" sequence="2" groups="product.group_product_variant" /> diff --git a/addons/product/product_wizard.xml b/addons/product/product_wizard.xml index f226cd4e543..77c65a8bd8c 100644 --- a/addons/product/product_wizard.xml +++ b/addons/product/product_wizard.xml @@ -1,11 +1,13 @@ <?xml version="1.0" ?> <openerp> <data> +<!-- <wizard id="report_wizard_price" string="Price List" model="product.product" name="product.price_list" keyword="client_print_multi"/> +--> </data> </openerp> diff --git a/addons/product/wizard/__init__.py b/addons/product/wizard/__init__.py index fed1bcf3783..7382a1fc2b1 100644 --- a/addons/product/wizard/__init__.py +++ b/addons/product/wizard/__init__.py @@ -18,7 +18,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -import wizard_price + +import product_price_list # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/wizard/product_price_list.py b/addons/product/wizard/product_price_list.py new file mode 100644 index 00000000000..9e39b009445 --- /dev/null +++ b/addons/product/wizard/product_price_list.py @@ -0,0 +1,49 @@ +# -*- 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 service import web_services +import time +import wizard +import pooler + +class product_price_list(osv.osv_memory): + _name = "product.price.list" + _description = "Product Price List" + + _columns = { + 'price_list': fields.many2one('product.pricelist', 'PriceList', required=True), + 'qty1':fields.integer('Quantity-1'), + 'qty2':fields.integer('Quantity-2'), + 'qty3':fields.integer('Quantity-3'), + 'qty4':fields.integer('Quantity-4'), + 'qty5':fields.integer('Quantity-5'), +} + + _defaults = { + 'qty1': lambda *a:'0', + 'qty2': lambda * a:'0', + 'qty3': lambda *a:'0', + 'qty4': lambda *a:'0', + 'qty5': lambda *a:'0', + } +product_price_list() + diff --git a/addons/product/wizard/product_price_list_view.xml b/addons/product/wizard/product_price_list_view.xml new file mode 100644 index 00000000000..370e04ff32e --- /dev/null +++ b/addons/product/wizard/product_price_list_view.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_product_price_view" model="ir.ui.view"> + <field name="name">Price list</field> + <field name="model">product.price.list</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Price list"> + <field name="price_list" colspan="2" /> + <field name="qty1" colspan="2" /> + <field name="qty2" colspan="2" /> + <field name="qty3" colspan="2" /> + <field name="qty4" colspan="2" /> + <field name="qty5" colspan="2" /> + <separator string="" colspan="4" /> + <label string="" colspan="2" /> + <button special="cancel" string="Cancel" /> + <button string="Print" type="object"/> + </form> + </field> + </record> + + <record id="action_product_price_view" model="ir.actions.act_window"> + <field name="name">Price List </field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">product.price.list</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="view_id" ref="view_product_price_view"/> + </record> + + </data> +</openerp> + diff --git a/addons/product_margin/__terp__.py b/addons/product_margin/__terp__.py index b0e81f341a7..dc7f13d6cb8 100644 --- a/addons/product_margin/__terp__.py +++ b/addons/product_margin/__terp__.py @@ -31,7 +31,8 @@ the report has several options to help you get the data you need. """, 'author': 'Tiny', 'depends': ['base', 'product', 'account'], - 'update_xml': ['product_margin_view.xml'], + 'update_xml': ['wizard/product_margin_view.xml', + 'product_margin_view.xml'], 'demo_xml': [], 'installable': True, 'active': False, diff --git a/addons/product_margin/product_margin_view.xml b/addons/product_margin/product_margin_view.xml index 03dfbdf2280..eaf64179015 100644 --- a/addons/product_margin/product_margin_view.xml +++ b/addons/product_margin/product_margin_view.xml @@ -1,15 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data> - - <wizard id="action_open_margin" menu="False" model="product.product" name="product.margins" string="Product Margins"/> - -<!-- <menuitem id="menu_product_reporting"--> -<!-- name="Reporting" parent ="product.menu_main_product"--> -<!-- groups="product.group_product_manager"/>--> -<!----> -<!-- <menuitem icon="STOCK_JUSTIFY_FILL" action="action_open_margin" id="menu_action_product_margin" type="wizard" sequence="5" parent="menu_product_reporting" />--> - <record model="ir.ui.view" id="view_product_margin_graph"> <field name="name">product.margin.graph</field> <field name="model">product.product</field> diff --git a/addons/product_margin/wizard/__init__.py b/addons/product_margin/wizard/__init__.py index 4e2ecc2e39a..578c1de3b78 100644 --- a/addons/product_margin/wizard/__init__.py +++ b/addons/product_margin/wizard/__init__.py @@ -19,7 +19,8 @@ # ############################################################################## -import wizard_product_margin + +import product_margin # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product_margin/wizard/product_margin.py b/addons/product_margin/wizard/product_margin.py new file mode 100644 index 00000000000..b82445bc874 --- /dev/null +++ b/addons/product_margin/wizard/product_margin.py @@ -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 time +from osv import osv +from osv import fields + +import netsvc +import time +from tools.translate import _ +class product_margin(osv.osv_memory): + ''' + Product Margin + ''' + _name = 'product.margin' + _description = 'Product Margin' + + def _action_open_window(self, cr, uid, ids, context): + """ + @summary: + + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: the account ID or list of IDs if we want more than one + + @return: + """ + mod_obj = self.pool.get('ir.model.data') + result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') + id = mod_obj.read(cr, uid, result, ['res_id']) + cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph')) + view_res3 = cr.fetchone()[0] + cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form')) + view_res2 = cr.fetchone()[0] + cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree')) + view_res = cr.fetchone()[0] + + #get the current product.margin object to obtain the values from it + product_margin_obj = self.browse(cr,uid,ids)[0] + + return { + 'name': _('Product Margins'), + 'context':{'date_from':product_margin_obj.from_date,'date_to':product_margin_obj.to_date,'invoice_state' : product_margin_obj.invoice_state}, + 'view_type': 'form', + "view_mode": 'tree,form,graph', + 'res_model':'product.product', + 'type': 'ir.actions.act_window', + 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')], + 'view_id': False, + 'search_view_id': id['res_id'] + } + + def action_cancel(self, cr, uid, ids, context=None): + """ + @summary: + + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: the account ID or list of IDs if we want more than one + + @return: + """ + return {'type':'ir.actions.act_window_close'} + + _columns = { + #TODO : import time required to get currect date + 'from_date': fields.datetime('From'), + #TODO : import time required to get currect date + 'to_date': fields.datetime('To'), + 'invoice_state':fields.selection([ + ('paid','Paid'), + ('open_paid','Open and Paid'), + ('draft_open_paid','Draft, Open and Paid'), + ],'Invoice State', select=True, required=True), + } + _defaults = { + 'from_date': lambda *a:time.strftime('%Y-01-01'), + 'to_date': lambda *a:time.strftime('%Y-01-01'), + 'invoice_state': lambda *a:"open_paid", + } +product_margin() diff --git a/addons/product_margin/wizard/product_margin_view.xml b/addons/product_margin/wizard/product_margin_view.xml new file mode 100644 index 00000000000..f7c292b576d --- /dev/null +++ b/addons/product_margin/wizard/product_margin_view.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="product_margin_form_view" model="ir.ui.view"> + <field name="name">product.margin.form</field> + <field name="model">product.margin</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Properties categories"> + <separator colspan="4" string="General Information"/> + <field name="from_date" /> + <field name="to_date" /> + <field name="invoice_state" /> + <group col="4" colspan="2"> + <button name="action_cancel" string="Cancel" type="object"/> + <button name="_action_open_window" string="Open Margins" type="object"/> + </group> + </form> + </field> + </record> + <record id="product_margin_action" model="ir.actions.act_window"> + <field name="name">Product Margine</field> + <field name="type">ir.actions.act_window</field> + <field name="target">new</field> + <field name="res_model">product.margin</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="product_margin_form_view"/> + </record> + <menuitem + action="product_margin_action" + id="menu_mrp_property_action" + parent="menu_product_reporting" /> + </data> +</openerp> diff --git a/addons/product_margin/wizard/wizard_product_margin.py b/addons/product_margin/wizard/wizard_product_margin.py deleted file mode 100644 index 625cfd4c1df..00000000000 --- a/addons/product_margin/wizard/wizard_product_margin.py +++ /dev/null @@ -1,93 +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 - -from tools.translate import _ - -def _action_open_window(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.model.data') - result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') - id = mod_obj.read(cr, uid, result, ['res_id']) - cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph')) - view_res3 = cr.fetchone()[0] - cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form')) - view_res2 = cr.fetchone()[0] - cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree')) - view_res = cr.fetchone()[0] - return { - 'name': _('Product Margins'), - 'context':{'date_from':data['form']['from_date'],'date_to':data['form']['to_date'],'invoice_state' : data['form']['invoice_state']}, - 'view_type': 'form', - "view_mode": 'tree,form,graph', - 'res_model':'product.product', - 'type': 'ir.actions.act_window', - 'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')], - 'view_id': False, - 'search_view_id': id['res_id'] - } - - -class product_margins(wizard.interface): - form1 = '''<?xml version="1.0"?> - <form string="View Stock of Products"> - <separator string="Select " colspan="4"/> - <field name="from_date"/> - <field name="to_date"/> - <field name="invoice_state"/> - </form>''' - form1_fields = { - 'from_date': { - 'string': 'From', - 'type': 'date', - 'default': lambda *a:time.strftime('%Y-01-01'), - - }, - 'to_date': { - 'string': 'To', - 'type': 'date', - 'default': lambda *a:time.strftime('%Y-12-31'), - - }, - 'invoice_state': { - 'string': 'Invoice State', - 'type': 'selection', - 'selection': [('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid'),], - 'required': True, - 'default': lambda *a:"open_paid", - }, - } - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Margins','gtk-ok')]} - }, - 'open': { - 'actions': [], - 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'} - } - } -product_margins('product.margins') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project_caldav/project_caldav_wizard.xml b/addons/project_caldav/project_caldav_wizard.xml index 2bb677eea46..53c78a99bf2 100644 --- a/addons/project_caldav/project_caldav_wizard.xml +++ b/addons/project_caldav/project_caldav_wizard.xml @@ -1,18 +1,5 @@ <openerp> <data> - <wizard string="Import .ics File" model="project.task" - name="calendar.event.import" id="caldav.wizard_cal_event_import" /> - - <wizard string="Subscribe" - model="project.task" name="calendar.event.subscribe" - id="caldav.wizard_cal_event_subscribe" /> - - <wizard string="Export .ics File" model="project.task" - name="calendar.event.export" id="caldav.wizard_cal_event_export" /> - - <wizard string="Edit this event" model="project.task" - name="calendar.event.edit.this" id="caldav.wizard_edit_this_event" - menu="False" /> </data> </openerp> diff --git a/addons/sale/__terp__.py b/addons/sale/__terp__.py index 70d9f084afb..f08a548fcf7 100644 --- a/addons/sale/__terp__.py +++ b/addons/sale/__terp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -45,6 +45,8 @@ 'depends': ['product', 'stock', 'mrp', 'process'], 'init_xml': [], 'update_xml': [ + 'wizard/sale_make_invoice_advance.xml', + 'wizard/sale_line_invoice.xml', 'security/sale_security.xml', 'security/ir.model.access.csv', 'sale_workflow.xml', diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index b3cec7496e4..2508ae0d6df 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -149,7 +149,12 @@ <field name="state" select="2"/> <group col="3" colspan="2"> <field name="invoiced" select="2"/> - <button colspan="1" name="%(wizard_sale_order_line_invoice)d" states="confirmed" string="Make Invoice" type="action" icon="gtk-print"/> + <button colspan="1" + name="%(action_view_sale_order_line_make_invoice)d" + states="confirmed" + string="Make Invoice" + type="action" + icon="gtk-print" /> </group> </page> <page groups="base.group_extended" string="Extra Info"> @@ -379,8 +384,14 @@ <separator colspan="4" string="States"/> <field name="state" select="2"/> <group col="2" colspan="2"> - <button name="button_done" states="confirmed,exception" string="Done" type="object" icon="gtk-jump-to"/> - <button name="button_cancel" states="confirmed,exception" string="Cancel" type="object" icon="gtk-cancel" /> + <button name="button_done" + states="confirmed,exception" + string="Done" type="object" + icon="gtk-jump-to" /> + <button name="button_cancel" + states="confirmed,exception" + string="Cancel" type="object" + icon="gtk-cancel" /> </group> </page> <page string="Properties"> diff --git a/addons/sale/sale_wizard.xml b/addons/sale/sale_wizard.xml index 9df05e8e5dd..c364c419857 100644 --- a/addons/sale/sale_wizard.xml +++ b/addons/sale/sale_wizard.xml @@ -10,19 +10,19 @@ multi="True" string="Make invoices"/> - <wizard - id="wizard_sale_order_line_invoice" - keyword="client_action_multi" - model="sale.order.line" - name="sale.order.line.make_invoice" - multi="True" - string="Make invoices"/> +<!-- <wizard--> +<!-- id="wizard_sale_order_line_invoice"--> +<!-- keyword="client_action_multi"--> +<!-- model="sale.order.line"--> +<!-- name="sale.order.line.make_invoice"--> +<!-- multi="True"--> +<!-- string="Make invoices"/>--> - <wizard string="Advance Invoice" + <!-- <wizard string="Advance Invoice" model="sale.order" name="sale.advance_payment_inv" id="sale.advance_payment" - menu="True"/> + menu="True"/> --> </data> </openerp> diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py index 6141e90b83b..07c5ceea83d 100644 --- a/addons/sale/wizard/__init__.py +++ b/addons/sale/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,13 +15,12 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -from make_invoice import make_invoice +#remaining make_invoice +import sale_line_invoice +import sale_make_invoice_advance -import wizard_sale_line_invoice -import make_invoice_advance # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/sale/wizard/make_invoice_advance.py b/addons/sale/wizard/make_invoice_advance.py deleted file mode 100644 index eaa1fc4a14b..00000000000 --- a/addons/sale/wizard/make_invoice_advance.py +++ /dev/null @@ -1,157 +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 -from osv import fields, osv -from tools.translate import _ - -form = """<?xml version="1.0"?> -<form string="Advance Payment"> - <field name="product_id"/> - <newline /> - <field name="qtty"/> - <field name="amount"/> - <newline /> -</form> -""" -fields = { - 'product_id': {'string':'Product', 'type':'many2one','relation':'product.product','required':True}, - 'amount': {'string':'Unit Price', 'type':'float', 'size':(16,2),'required':True}, - 'qtty': {'string':'Quantity', 'type':'float', 'size':(16,2),'required':True, 'default': lambda *a: 1}, -} - -form_msg = """<?xml version="1.0"?> -<form string="Invoices"> - <label string="You invoice has been successfully created !"/> -</form> -""" -fields_msg = {} - -def _createInvoices(self, cr, uid, data, context={}): - list_inv = [] - pool_obj = pooler.get_pool(cr.dbname) - obj_sale = pool_obj.get('sale.order') - data_sale = obj_sale.browse(cr,uid,data['ids']) - obj_lines = pool_obj.get('account.invoice.line') - for sale in data_sale: - address_contact = False - address_invoice = False - create_ids = [] - ids_inv = [] - if sale.order_policy == 'postpaid': - raise osv.except_osv( - _('Error'), - _("You cannot make an advance on a sale order that is defined as 'Automatic Invoice after delivery'.")) - val = obj_lines.product_id_change(cr, uid, [], data['form']['product_id'],uom = False, partner_id = sale.partner_id.id, fposition_id=sale.fiscal_position.id) - line_id =obj_lines.create(cr, uid, { - 'name': val['value']['name'], - 'account_id':val['value']['account_id'], - 'price_unit': data['form']['amount'], - 'quantity': data['form']['qtty'], - 'discount': False, - 'uos_id': val['value']['uos_id'], - 'product_id':data['form']['product_id'], - 'invoice_line_tax_id': [(6,0,val['value']['invoice_line_tax_id'])], - 'account_analytic_id': sale.project_id and sale.project_id.id or False, - 'note':'', - }) - create_ids.append(line_id) - inv = { - 'name': sale.name, - 'origin': sale.name, - 'type': 'out_invoice', - 'reference': False, - 'account_id': sale.partner_id.property_account_receivable.id, - 'partner_id': sale.partner_id.id, - 'address_invoice_id':sale.partner_invoice_id.id, - 'address_contact_id':sale.partner_order_id.id, - 'invoice_line': [(6,0,create_ids)], - 'currency_id' :sale.pricelist_id.currency_id.id, - 'comment': '', - 'payment_term':sale.payment_term.id, - 'fiscal_position': sale.partner_id.property_account_position.id - } - inv_obj = pool_obj.get('account.invoice') - inv_id = inv_obj.create(cr, uid, inv) - - for inv in sale.invoice_ids: - ids_inv.append(inv.id) - ids_inv.append(inv_id) - obj_sale.write(cr,uid,sale.id,{'invoice_ids':[(6,0,ids_inv)]}) - list_inv.append(inv_id) -# -# If invoice on picking: add the cost on the SO -# If not, the advance will be deduced when generating the final invoice -# - if sale.order_policy=='picking': - pool_obj.get('sale.order.line').create(cr, uid, { - 'order_id': sale.id, - 'name': val['value']['name'], - 'price_unit': -data['form']['amount'], - 'product_uom_qty': data['form']['qtty'], - 'product_uos_qty': data['form']['qtty'], - 'product_uos': val['value']['uos_id'], - 'product_uom': val['value']['uos_id'], - 'product_id':data['form']['product_id'], - 'discount': False, - 'tax_id': [(6,0,val['value']['invoice_line_tax_id'])], - }, context) - return {'invoice_ids':list_inv} - -class sale_advance_payment(wizard.interface): - def _open_invoice(self, cr, uid, data, context): - pool_obj = pooler.get_pool(cr.dbname) - mod_obj = pool_obj.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']) - model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','invoice_form')]) - resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id'] - return { - 'domain': "[('id','in', ["+','.join(map(str,data['form']['invoice_ids']))+"])]", - 'name': 'Invoices', - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'account.invoice', - 'views': [(False,'tree'),(resource_id,'form')], - 'context': "{'type':'out_invoice'}", - 'type': 'ir.actions.act_window', - 'search_view_id': id['res_id'] - } - - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'form' , 'arch' : form,'fields' : fields,'state' : [('end','Cancel','gtk-cancel'),('create','Create Advance Invoice','gtk-ok')]} - }, - 'create': { - 'actions': [_createInvoices], - 'result': {'type' : 'form' ,'arch' : form_msg,'fields' : fields_msg, 'state':[('end','Close','gtk-close'),('open','Open Advance Invoice','gtk-open')]} - }, - 'open': { - 'actions': [], - 'result': {'type':'action', 'action':_open_invoice, 'state':'end'} - } - } - -sale_advance_payment("sale.advance_payment_inv") -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py new file mode 100644 index 00000000000..7dd7fef78cb --- /dev/null +++ b/addons/sale/wizard/sale_line_invoice.py @@ -0,0 +1,100 @@ +# -*- 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 service import web_services +import wizard +import netsvc +import ir +import pooler + +class sale_order_line_make_invoice(osv.osv_memory): + _name = "sale.order.line.make.invoice" + _description = "Sale OrderLine Make_invoice" + _columns = { + 'grouped': fields.boolean('Group the invoices'), + } + _default = { + 'grouped' : lambda *a: False + } + + def makeInvoices(self, cr, uid, ids, context): + res = False + invoices = {} + + #TODO: merge with sale.py/make_invoice + def make_invoice(order, lines): + a = order.partner_id.property_account_receivable.id + if order.partner_id and order.partner_id.property_payment_term.id: + pay_term = order.partner_id.property_payment_term.id + else: + pay_term = False + inv = { + 'name': order.name, + 'origin': order.name, + 'type': 'out_invoice', + 'reference': "P%dSO%d" % (order.partner_id.id, order.id), + 'account_id': a, + 'partner_id': order.partner_id.id, + 'address_invoice_id': order.partner_invoice_id.id, + 'address_contact_id': order.partner_invoice_id.id, + 'invoice_line': [(6,0,lines)], + 'currency_id' : order.pricelist_id.currency_id.id, + 'comment': order.note, + 'payment_term': pay_term, + 'fiscal_position': order.partner_id.property_account_position.id + } + inv_id = self.pool.get('account.invoice').create(cr, uid, inv) + return inv_id + + for line in self.pool.get('sale.order.line').browse(cr,uid,context['active_ids']): + if (not line.invoiced) and (line.state not in ('draft','cancel')): + if not line.order_id.id in invoices: + invoices[line.order_id.id] = [] + line_id = self.pool.get('sale.order.line').invoice_line_create(cr, uid, + [line.id]) + for lid in line_id: + invoices[line.order_id.id].append((line, lid)) + self.pool.get('sale.order.line').write(cr, uid, [line.id], + {'invoiced': True}) + flag = True + data_sale = self.pool.get('sale.order').browse(cr,uid,line.order_id.id) + for line in data_sale.order_line: + if not line.invoiced: + flag = False + break + if flag: + wf_service = netsvc.LocalService('workflow') + wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr) + self.pool.get('sale.order').write(cr,uid,[line.order_id.id],{'state' : 'progress'}) + + for result in invoices.values(): + order = result[0][0].order_id + il = map(lambda x: x[1], result) + res = make_invoice(order, il) + cr.execute('INSERT INTO sale_order_invoice_rel \ + (order_id,invoice_id) values (%s,%s)', (order.id, res)) + return {} + + +sale_order_line_make_invoice() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/wizard/sale_line_invoice.xml b/addons/sale/wizard/sale_line_invoice.xml new file mode 100644 index 00000000000..823b5a04662 --- /dev/null +++ b/addons/sale/wizard/sale_line_invoice.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_sale_order_line_make_invoice" model="ir.ui.view"> + <field name="name">Sale OrderLine Make Invoice</field> + <field name="model">sale.order.line.make.invoice</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create invoices"> + <separator colspan="4" string="Do you really want to create the invoices ?" /> + <field name="grouped" /> + <separator string="" colspan="6" /> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="makeInvoices" string="Create Invoices" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <record id="action_view_sale_order_line_make_invoice" model="ir.actions.act_window"> + <field name="name">Make Invoices</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">sale.order.line.make.invoice</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="sale_make_invoice"> + <field name="model_id" ref="sale.model_sale_order_line" /> + <field name="object" eval="1" /> + <field name="name">Make Invoices</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_sale_order_line_make_invoice'))" /> + <field name="key">action</field> + <field name="model">sale.order.line</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py new file mode 100644 index 00000000000..9a079c4f8ec --- /dev/null +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -0,0 +1,154 @@ +############################################################################## +# +# 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 service import web_services +from tools.translate import _ +import ir +import netsvc +import pooler +import wizard + + +class sale_advance_payment_inv(osv.osv_memory): + _name = "sale.advance.payment.inv" + _description = "Sale Advance Payment Invoice" + _columns = { + 'product_id': fields.many2one('product.product', 'Product', required=True), + 'amount': fields.float('Unit Price', size=(16, 2), required=True), + 'qtty': fields.float('Quantity', size=(16, 2), required=True), + } + _default = { + 'qtty' : lambda *a: 1 + } + def createInvoices(self, cr, uid, ids, context={}): + list_inv = [] + obj_sale = self.pool.get('sale.order') + obj_lines = self.pool.get('account.invoice.line') + for sale_adv_obj in self.browse(cr, uid, ids): + for sale in obj_sale.browse(cr, uid, context['active_ids']): + address_contact = False + address_invoice = False + create_ids = [] + ids_inv = [] + if sale.order_policy == 'postpaid': + raise osv.except_osv( + _('Error'), + _("You cannot make an advance on a sale order \ + that is defined as 'Automatic Invoice after delivery'.")) + val = obj_lines.product_id_change(cr, uid, [], sale_adv_obj.product_id.id, + uom = False, partner_id = sale.partner_id.id, fposition_id=sale.fiscal_position.id) + line_id =obj_lines.create(cr, uid, { + 'name': val['value']['name'], + 'account_id': val['value']['account_id'], + 'price_unit': sale_adv_obj.amount, + 'quantity': sale_adv_obj.qtty, + 'discount': False, + 'uos_id': val['value']['uos_id'], + 'product_id': sale_adv_obj.product_id.id, + 'invoice_line_tax_id': [(6, 0, val['value']['invoice_line_tax_id'])], + 'account_analytic_id': sale.project_id.id or False, + #'note':'', + }) + create_ids.append(line_id) + inv = { + 'name': sale.name, + 'origin': sale.name, + 'type': 'out_invoice', + 'reference': False, + 'account_id': sale.partner_id.property_account_receivable.id, + 'partner_id': sale.partner_id.id, + 'address_invoice_id':sale.partner_invoice_id.id, + 'address_contact_id':sale.partner_order_id.id, + 'invoice_line': [(6, 0, create_ids)], + 'currency_id' :sale.pricelist_id.currency_id.id, + 'comment': '', + 'payment_term':sale.payment_term.id, + 'fiscal_position': sale.partner_id.property_account_position.id + } + inv_obj = self.pool.get('account.invoice') + inv_id = inv_obj.create(cr, uid, inv) + + for inv in sale.invoice_ids: + ids_inv.append(inv.id) + ids_inv.append(inv_id) + obj_sale.write(cr, uid, sale.id, {'invoice_ids':[(6, 0, ids_inv)]}) + list_inv.append(inv_id) + # + # If invoice on picking: add the cost on the SO + # If not, the advance will be deduced when generating the final invoice + # + if sale.order_policy=='picking': + self.pool.get('sale.order.line').create(cr, uid, { + 'order_id': sale.id, + 'name': val['value']['name'], + 'price_unit': -sale_adv_obj.amount, + 'product_uom_qty': sale_adv_obj.qtty, + 'product_uos_qty': sale_adv_obj.qtty, + 'product_uos': val['value']['uos_id'], + 'product_uom': val['value']['uos_id'], + 'product_id': sale_adv_obj.product_id.id, + 'discount': False, + 'tax_id': [(6, 0, val['value']['invoice_line_tax_id'])], + }, context) + + return {#'invoice_ids':list_inv, + 'name': 'Open Invoice', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'sale.open.invoice', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': "{'invoice_ids'=%s}" % (list_inv) + } + +sale_advance_payment_inv() + +class sale_open_invoice(osv.osv_memory): + _name = "sale.open.invoice" + _description = "Sale Open Invoice" + _columns = { + } + + def open_invoice(self, cr, uid, ids, context): + mod_obj = self.pool.get('ir.model.data') + invoices = [] + #TODO: Can not get invoice ids here + for advance_pay in self.browse(cr, uid, ids): + result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') + id = mod_obj.read(cr, uid, result, ['res_id']) + model_data_ids = self.pool.get('ir.model.data').search(cr, uid, + [('model', '=', 'ir.ui.view'), ('name', '=', 'invoice_form')]) + resource_id = self.pool.get('ir.model.data').read(cr, uid, model_data_ids, + fields=['res_id'])[0]['res_id'] + return { +# 'domain': "[('id','in', ["+','.join(map(str, invoices))+"])]", # TODO + 'name': 'Invoices', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'account.invoice', + 'views': [(False, 'tree'), (resource_id, 'form')], + 'context': "{'type':'out_invoice'}", + 'type': 'ir.actions.act_window', + 'search_view_id': id['res_id'] + } +sale_open_invoice() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/wizard/sale_make_invoice_advance.xml b/addons/sale/wizard/sale_make_invoice_advance.xml new file mode 100644 index 00000000000..eb333f42b64 --- /dev/null +++ b/addons/sale/wizard/sale_make_invoice_advance.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_sale_advance_payment_inv" model="ir.ui.view"> + <field name="name">Sale Advance Payment Invoive</field> + <field name="model">sale.advance.payment.inv</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Advance Payment"> + <field name="product_id"/> + <newline /> + <field name="qtty"/> + <field name="amount"/> + <newline /> + <separator string="" colspan="4"/> + <label string="" colspan="2" /> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="createInvoices" string="Create Advance Invoice" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <record id="action_view_sale_advance_payment_inv" model="ir.actions.act_window"> + <field name="name">Advance Invoice</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">sale.advance.payment.inv</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="sale_advance_payment_inv1"> + <field name="model_id" ref="sale.model_sale_order" /> + <field name="object" eval="1" /> + <field name="name">Advance Invoice</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_sale_advance_payment_inv'))" /> + <field name="key">action</field> + <field name="model">sale.order</field> + </record> + + + <record id="view_sale_open_invoice" model="ir.ui.view"> + <field name="name">Open Invoice</field> + <field name="model">sale.open.invoice</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Invoices"> + <label string="You invoice has been successfully created!" /> + <newline /> + <separator string="" colspan="4"/> + <group colspan="4"> + <button special="cancel" string="Cancel" icon="gtk-cancel"/> + <button name="open_invoice" string="Open Invoice" type="object" icon="gtk-open"/> + </group> + </form> + </field> + </record> + + <record id="action_view_sale_open_invoice" model="ir.actions.act_window"> + <field name="name">Open Invoice</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">sale.open.invoice</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + </data> +</openerp> diff --git a/addons/sale/wizard/wizard_sale_line_invoice.py b/addons/sale/wizard/wizard_sale_line_invoice.py deleted file mode 100644 index 8e1e49ab22d..00000000000 --- a/addons/sale/wizard/wizard_sale_line_invoice.py +++ /dev/null @@ -1,121 +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 ir -import pooler - -invoice_form = """<?xml version="1.0"?> -<form string="Create invoices"> - <separator colspan="4" string="Do you really want to create the invoices ?" /> - <field name="grouped" /> -</form> -""" - -invoice_fields = { - 'grouped' : {'string':'Group the invoices', 'type':'boolean', 'default': lambda *a: False} -} - -def _makeInvoices(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - res = False - invoices = {} - - #TODO: merge with sale.py/make_invoice - def make_invoice(order, lines): - a = order.partner_id.property_account_receivable.id - if order.partner_id and order.partner_id.property_payment_term.id: - pay_term = order.partner_id.property_payment_term.id - else: - pay_term = False - inv = { - 'name': order.name, - 'origin': order.name, - 'type': 'out_invoice', - 'reference': "P%dSO%d" % (order.partner_id.id, order.id), - 'account_id': a, - 'partner_id': order.partner_id.id, - 'address_invoice_id': order.partner_invoice_id.id, - 'address_contact_id': order.partner_invoice_id.id, - 'invoice_line': [(6,0,lines)], - 'currency_id' : order.pricelist_id.currency_id.id, - 'comment': order.note, - 'payment_term': pay_term, - 'fiscal_position': order.partner_id.property_account_position.id - } - inv_id = pool.get('account.invoice').create(cr, uid, inv) - return inv_id - - for line in pool.get('sale.order.line').browse(cr,uid,data['ids']): - if (not line.invoiced) and (line.state not in ('draft','cancel')): - if not line.order_id.id in invoices: - invoices[line.order_id.id] = [] - line_id = pool.get('sale.order.line').invoice_line_create(cr, uid, - [line.id]) - for lid in line_id: - invoices[line.order_id.id].append((line, lid)) - pool.get('sale.order.line').write(cr, uid, [line.id], - {'invoiced': True}) - flag = True - data_sale = pool.get('sale.order').browse(cr,uid,line.order_id.id) - for line in data_sale.order_line: - if not line.invoiced: - flag = False - break - if flag: - wf_service = netsvc.LocalService('workflow') - wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr) - pool.get('sale.order').write(cr,uid,[line.order_id.id],{'state' : 'progress'}) - - for result in invoices.values(): - order = result[0][0].order_id - il = map(lambda x: x[1], result) - res = make_invoice(order, il) - cr.execute('INSERT INTO sale_order_invoice_rel \ - (order_id,invoice_id) values (%s,%s)', (order.id, res)) - return {} - - -class line_make_invoice(wizard.interface): - states = { - 'init' : { - 'actions': [], - 'result': { - 'type': 'form', - 'arch': invoice_form, - 'fields': invoice_fields, - 'state': [ - ('end', 'Cancel'), - ('invoice', 'Create invoices') - ] - } - }, - 'invoice' : { - 'actions' : [_makeInvoices], - 'result' : {'type': 'state', 'state': 'end'} - }, - } - -line_make_invoice("sale.order.line.make_invoice") - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py index d728efbf2fe..12a218a31be 100644 --- a/addons/stock/__init__.py +++ b/addons/stock/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -26,9 +26,9 @@ import product import report import wizard import report_stock - import stock_wizard + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/__terp__.py b/addons/stock/__terp__.py index 8081c4b6738..ba5e435fcbb 100644 --- a/addons/stock/__terp__.py +++ b/addons/stock/__terp__.py @@ -41,11 +41,16 @@ Thanks to the double entry management, the inventory controlling is powerful and "init_xml" : [], "demo_xml" : ["stock_demo.xml"], "update_xml" : [ - "stock_workflow.xml", "stock_data.xml", + "wizard/stock_inventory_set_stock_zero_view.xml", + "wizard/stock_fill_inventory_view.xml", + "wizard/stock_invoice_onshipping_view.xml", + "wizard/stock_location_product_view.xml", + "wizard/stock_inventory_line_split_view.xml", + "stock_workflow.xml", "stock_incoterms.xml", "stock_wizard.xml", - "stock_wizard_view.xml", + "stock_wizard_view.xml", "stock_view.xml", "stock_report.xml", "stock_sequence.xml", diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a403c141be4..3c6fdfc9ab2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -223,7 +223,7 @@ class stock_location(osv.osv): # Take the user company and pricetype price_type_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) - + if not product_ids: product_ids = product_obj.search(cr, uid, []) @@ -254,10 +254,10 @@ class stock_location(osv.osv): continue product = products_by_id[product_id] quantity_total += qty[product_id] - + # Compute based on pricetype # Choose the right filed standard_price to read - amount_unit=product.price_get(pricetype.field, context)[product.id] + amount_unit=product.price_get(pricetype.field, context)[product.id] price = qty[product_id] * amount_unit # price = qty[product_id] * product.standard_price @@ -661,13 +661,13 @@ class stock_picking(osv.osv): '''Return comment string for invoice''' return picking.note or '' - def _get_price_unit_invoice(self, cursor, user, move_line, type): + def _get_price_unit_invoice(self, cr, users, move_line, type): '''Return the price unit for the move line''' if type in ('in_invoice', 'in_refund'): # Take the user company and pricetype - price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id - pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) - amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id] + price_type_id=self.pool.get('res.users').browse(cr, users, users).company_id.property_valuation_price_type.id + pricetype=self.pool.get('product.price.type').browse(cr, users, price_type_id) + amount_unit=move_line.product_id.price_get(pricetype.field, context={})[move_line.product_id.id] return amount_unit else: return move_line.product_id.list_price @@ -1383,12 +1383,12 @@ class stock_move(osv.osv): # Base computation on valuation price type else: company_id=move.company_id.id - + pricetype=self.pool.get('product.price.type').browse(cr,uid,move.company_id.property_valuation_price_type.id) amount_unit=move.product_id.price_get(pricetype.field, context)[move.product_id.id] amount=amount_unit * q or 1.0 # amount = q * move.product_id.standard_price - + partner_id = False if move.picking_id: partner_id = move.picking_id.address_id and (move.picking_id.address_id.partner_id and move.picking_id.address_id.partner_id.id or False) or False @@ -1434,7 +1434,7 @@ class stock_move(osv.osv): raise osv.except_osv(_('UserError'), _('You can only delete draft moves.')) return super(stock_move, self).unlink( - cr, uid, ids, context=context) + cr, uid, ids, context=context) def _create_lot(self, cr, uid, ids, product_id, prefix=False): prodlot_obj = self.pool.get('stock.production.lot') @@ -1442,23 +1442,31 @@ class stock_move(osv.osv): sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') if not sequence: raise wizard.except_wizard(_('Error!'), _('No production sequence defined')) + new_move = [] + + def _create_lot(move_id, product_id): + prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id}) + prodlot = prodlot_obj.browse(cr, uid, prodlot_id) + ref = '%d' % (move_id) + if prodlot.ref: + ref = '%s, %s' % (prodlot.ref, ref) + prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref}) + return prodlot_id prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id}) - prodlot = prodlot_obj.browse(cr, uid, prodlot_id) + prodlot = prodlot_obj.browse(cr, uid, prodlot_id) ref = ','.join(map(lambda x:str(x),ids)) if prodlot.ref: - ref = '%s, %s' % (prodlot.ref, ref) + ref = '%s, %s' % (prodlot.ref, ref) prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref}) return prodlot_id def split_lines(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None): - if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) res = [] - - for move in self.browse(cr, uid, ids): + for move in self.browse(cr, uid, ids): if split_by_qty <= 0 or quantity == 0: return res @@ -1470,8 +1478,18 @@ class stock_move(osv.osv): update_val = { 'product_qty': split_by_qty, 'product_uos_qty': uos_qty, - } - for idx in range(int(quantity//split_by_qty)): + } + + for idx in range(int(quantity//split_by_qty)): + if idx: + current_move = self.copy(cr, uid, move.id, {'state': move.state}) + new_move.append(current_move) + else: + update_val = { + 'product_qty': split_by_qty, + 'product_uos_qty': uos_qty, + } + for idx in range(int(quantity//split_by_qty)): if not idx and move.product_qty<=quantity: current_move = move.id else: @@ -1481,94 +1499,154 @@ class stock_move(osv.osv): update_val['prodlot_id'] = self._create_lot(cr, uid, [current_move], move.product_id.id) self.write(cr, uid, [current_move], update_val) - - - if quantity_rest > 0: - idx = int(quantity//split_by_qty) + if quantity_rest > 0: + idx = int(quantity//split_by_qty) + + if quantity_rest > 0: + idx = int(quantity//split_by_qty) update_val['product_qty'] = quantity_rest - update_val['product_uos_qty'] = uos_qty_rest - if not idx and move.product_qty<=quantity: - current_move = move.id + update_val['product_uos_qty'] = uos_qty_rest + if idx: + current_move = self.copy(cr, uid, move.id, {'state': move.state}) + new_move.append(current_move) + update_val['product_uos_qty'] = uos_qty_rest + if not idx and move.product_qty<=quantity: + current_move = move.id else: - current_move = self.copy(cr, uid, move.id, {'state': move.state}) - + current_move = move.id + update_val['prodlot_id'] = _create_lot(current_move, move.product_id.id) + current_move = self.copy(cr, uid, move.id, {'state': move.state}) + res.append(current_move) - - - if with_lot: + + + if with_lot: update_val['prodlot_id'] = self._create_lot(cr, uid, [current_move], move.product_id.id) self.write(cr, uid, [current_move], update_val) - return res + return res - def consume_moves(self, cr, uid, ids, quantity, location_id=False, location_dest_id=False, consume=True, context=None): + def consume_moves(self, cr, uid, ids, quantity, location_id=False, location_dest_id=False, consume=True, context=None): if not context: context = {} - + context = {} + if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) - res = [] - for move in self.browse(cr, uid, ids, context=context): + for move in self.browse(cr, uid, ids, context=context): + + res = [] + for move in self.browse(cr, uid, ids, context=context): move_qty = move.product_qty quantity_rest = move.product_qty - quantity_rest -= quantity + quantity_rest -= quantity uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty if quantity_rest <= 0: - quantity_rest = 0 + quantity_rest = quantity + break + + default_val = { + 'product_qty': quantity, + 'product_uos_qty': uos_qty, + 'location_id': location_id or move.location_id.id, + } + if move.product_id.track_production: + new_move = self.split_lines(cr, uid, [move.id], quantity, split_by_qty=1, context=context) + else: + current_move = self.copy(cr, uid, move.id, default_val) + new_move.append(current_move) + + update_val = {} + if quantity_rest > 0: + quantity_rest = 0 uos_qty_rest = 0 quantity = move.product_qty - + uos_qty = quantity / move_qty * move.product_uos_qty - if quantity_rest > 0: + if quantity_rest > 0: default_val = { - 'product_qty': quantity, - 'product_uos_qty': uos_qty, - 'state': move.state, + 'product_qty': quantity, + 'product_uos_qty': uos_qty, + 'state': move.state, } if location_dest_id: - default_val.update({'location_dest_id': location_dest_id}) + default_val.update({'location_dest_id': location_dest_id}) if location_id: - default_val.update({'location_id': location_id}) - + default_val.update({'location_id': location_id}) + if move.product_id.track_production and location_id: res += self.split_lines(cr, uid, [move.id], quantity, split_by_qty=1, context=context) else: current_move = self.copy(cr, uid, move.id, default_val) res += [current_move] - update_val = {} + update_val = {} update_val['product_qty'] = quantity_rest - update_val['product_uos_qty'] = uos_qty_rest - self.write(cr, uid, [move.id], update_val) + update_val['product_uos_qty'] = uos_qty_rest + self.write(cr, uid, [move.id], update_val) + + self.action_done(cr, uid, new_move) + return new_move + update_val['product_uos_qty'] = uos_qty_rest + self.write(cr, uid, [move.id], update_val) - else: - quantity_rest = quantity + else: + quantity_rest = quantity uos_qty_rest = uos_qty - + if move.product_id.track_production and location_id: res += self.split_lines(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context) - else: - res += [move.id] - update_val = {} + else: + res += [move.id] + update_val = {} update_val['product_qty'] = quantity_rest update_val['product_uos_qty'] = uos_qty_rest if location_dest_id: - update_val.update({'location_dest_id': location_dest_id}) + update_val.update({'location_dest_id': location_dest_id}) if location_id: - update_val.update({'location_id': location_id}) + update_val.update({'location_id': location_id}) self.write(cr, uid, [move.id], update_val) if consume: - self.action_done(cr, uid, res) + self.action_done(cr, uid, res) return res def scrap_moves(self, cr, uid, ids, quantity, location_dest_id, context=None): - return self.consume_moves(cr, uid, ids, quantity, location_id=False, location_dest_id=location_dest_id, consume=False, context=context) + new_move = [] + if quantity <= 0: + raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) + for move in self.browse(cr, uid, ids, context=context): + location = move.location_dest_id.id + move_qty = move.product_qty + quantity_rest = move.product_qty + + quantity_rest -= quantity + uos_qty = quantity / move_qty * move.product_uos_qty + uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty + if quantity_rest <= 0: + quantity_rest = quantity + break + + default_val = { + 'product_qty': quantity, + 'product_uos_qty': uos_qty, + 'location_dest_id': location_dest_id, + 'state': move.state + } + current_move = self.copy(cr, uid, move.id, default_val) + new_move.append(current_move) + update_val = {} + if quantity_rest > 0: + update_val['product_qty'] = quantity_rest + update_val['product_uos_qty'] = uos_qty_rest + self.write(cr, uid, [move.id], update_val) + return new_move + return self.consume_moves(cr, uid, ids, quantity, location_id=False, location_dest_id=location_dest_id, consume=False, context=context) stock_move() @@ -1599,7 +1677,7 @@ class stock_inventory(osv.osv): move_line = [] for line in inv.inventory_line_id: pid = line.product_id.id - + # price = line.product_id.standard_price or 0.0 amount = self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id})[pid] change = line.product_qty - amount diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 3cada5cbb6d..c112ab44d5e 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -33,7 +33,12 @@ <field name="product_uom"/> <field name="prod_lot_id"/> <field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/> - <button name="%(split_inventory_lots)d" string="Split Inventory Lines" type="action" icon="gtk-justify-fill"/> + <!-- <button name="%(split_inventory_lots)d" + string="Split Inventory Lines" type="action" + icon="gtk-justify-fill" /> --> + <button name="%(stock.action_view_stock_inventory_line_split)d" + string="Split inventory lines" + type="action" icon="gtk-justify-fill"/> </form> </field> </record> @@ -50,6 +55,7 @@ <field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/> </group> </search> + </field> </record> @@ -64,6 +70,7 @@ <field name="state"/> </tree> </field> + </record> <record id="view_inventory_form" model="ir.ui.view"> <field name="name">stock.inventory.form</field> @@ -89,11 +96,12 @@ <field name="product_qty"/> <field name="product_uom"/> <field domain="[('usage','=','internal')]" name="location_id" select="1"/> + <field name="prod_lot_id"/> <group colspan="2" col="3"> - <field name="prod_lot_id"/> - <button name="%(split_inventory_lots)d" string="Split in Production Lots" type="action" icon="gtk-justify-fill"/> - </group> - + <button name="%(stock.action_view_stock_inventory_line_split)d" + string="Split inventory lines" + type="action" icon="gtk-justify-fill"/> + </group> </form> </field> </page><page string="Posted Inventory"> @@ -106,6 +114,7 @@ <button name="action_cancel" states="cancel" string="Set to Draft" type="object" icon="gtk-cancel"/> <button name="action_cancel_inventary" states="draft" string="Cancel Inventory" type="object" icon="gtk-cancel"/> </group> + </form> </field> </record> @@ -138,6 +147,9 @@ <field name="name" select="1"/> <field name="serial" select="1"/> <field name="date" select="1"/> + <field name="active" select="1"/> + <group colspan="4"> + </group> <field name="active" /> </form> </field> @@ -524,7 +536,7 @@ <field name="auto_refresh" eval="1"/> <field name="target">new</field> <field name="context">{'action_id': active_id}</field> - </record> + </record> <record model="ir.ui.view" id="stock_picking_calendar"> <field name="name">stock.picking.calendar</field> @@ -585,7 +597,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> <button name="%(stock.track_line)d" string="Split in production lots" @@ -662,6 +674,9 @@ <field name="move_type"/> </page> </notebook> + <button + name="%(stock.action_stock_invoice_onshipping)d" + string="Create Invoices" type="action" /> </form> </field> </record> @@ -726,6 +741,7 @@ <field name="min_date" select="1"/> <field name="type"/> <field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/> + </group> <notebook colspan="4"> <page string="General Information"> @@ -740,7 +756,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> <button name="%(stock.track_line)d" string="Split in production lots" @@ -812,6 +828,9 @@ <field name="move_type"/> </page> </notebook> + <button + name="%(stock.action_stock_invoice_onshipping)d" + string="Create Invoice" type="action" /> </form> </field> </record> @@ -890,9 +909,6 @@ <field name="state"/> <button name="%(partial_picking)d" states="assigned" string="Validate" type="action" icon="gtk-go-forward" help="Validate Picking"/> <button name="button_cancel" states="assigned,confirmed,draft" string="Cancel" icon="gtk-cancel" help="Cancel" confirm="This operation will cancel the picking. Do you want to continue?"/> - <button name="%(wizard_invoice_onshipping)d" states="done" string="Invoice" type="action" - icon="gtk-execute" help="Create invoice" - attrs="{'invisible': [('invoice_state', '!=', '2binvoiced')]}" /> </tree> </field> </record> @@ -925,7 +941,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> <button name="%(stock.track_line)d" string="Split in production lots" @@ -1110,8 +1126,8 @@ name="%(stock.move_scrap)d" string="D" type="action" icon="gtk-convert" - states="draft,waiting,confirmed,assigned" /> - </tree> + states="done,cancel" /> + </tree> <form string="Stock Moves"> <notebook colspan="4"> <page string="General Information"> @@ -1278,7 +1294,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> </tree> </field> </record> @@ -1317,7 +1333,7 @@ <field name="date"/> <field name="date_planned"/> <field name="priority"/> - </group> + </group> <group colspan="2" col="4"> <separator string="Tracability" colspan="4" /> @@ -1327,7 +1343,7 @@ domain="[('product_id','=?',product_id)]" on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/> <button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill" colspan="2" /> - </group> + </group> </page> <page string="Return Picking History"> <field name="move_stock_return_history" nolabel="1"/> diff --git a/addons/stock/stock_wizard.py b/addons/stock/stock_wizard.py index 548375db199..eefeeec4ad8 100644 --- a/addons/stock/stock_wizard.py +++ b/addons/stock/stock_wizard.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -25,16 +25,16 @@ from tools.translate import _ class stock_move_track(osv.osv_memory): _name = "stock.move.track" _description = "Track moves" - + _columns = { - 'tracking_prefix': fields.char('Tracking prefix', size=64), + 'tracking_prefix': fields.char('Tracking prefix', size=64), 'quantity': fields.float("Quantity per lot") } _defaults = { 'quantity': lambda *x: 1 } - + def track_lines(self, cr, uid, ids, context={}): datas = self.read(cr, uid, ids)[0] move_obj = self.pool.get('stock.move') @@ -46,43 +46,43 @@ stock_move_track() class stock_move_consume(osv.osv_memory): _name = "stock.move.consume" _description = "Consume Products" - + _columns = { - 'product_id': fields.many2one('product.product', 'Product', required=True, select=True), - 'product_qty': fields.float('Quantity', required=True), - 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), + 'product_id': fields.many2one('product.product', 'Product', required=True, select=True), + 'product_qty': fields.float('Quantity', required=True), + 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), 'location_id': fields.many2one('stock.location', 'Location', required=True) } def _get_product_id(self, cr, uid, context): move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) return move.product_id.id - + def _get_product_qty(self, cr, uid, context): move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) return move.product_qty - + def _get_product_uom(self, cr, uid, context): move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) return move.product_uom.id - + def _get_location_id(self, cr, uid, context): move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) return move.location_id.id - + _defaults = { - 'product_id': _get_product_id, - 'product_qty': _get_product_qty, - 'product_uom': _get_product_uom, + 'product_id': _get_product_id, + 'product_qty': _get_product_qty, + 'product_uom': _get_product_uom, 'location_id': _get_location_id } def do_move_consume(self, cr, uid, ids, context={}): move_obj = self.pool.get('stock.move') move_ids = context['active_ids'] - for data in self.read(cr, uid, ids): - move_obj.consume_moves(cr, uid, move_ids, - data['product_qty'], data['location_id'], + for data in self.read(cr, uid, ids): + move_obj.consume_moves(cr, uid, move_ids, + data['product_qty'], data['location_id'], context=context) return {} @@ -93,17 +93,17 @@ class stock_move_scrap(osv.osv_memory): _name = "stock.move.scrap" _description = "Scrap Products" _inherit = "stock.move.consume" - + _defaults = { 'location_id': lambda *x: False - } + } def move_scrap(self, cr, uid, ids, context={}): - move_obj = self.pool.get('stock.move') + move_obj = self.pool.get('stock.move') move_ids = context['active_ids'] for data in self.read(cr, uid, ids): - move_obj.scrap_moves(cr, uid, move_ids, - data['product_qty'], data['location_id'], + move_obj.scrap_moves(cr, uid, move_ids, + data['product_qty'], data['location_id'], context=context) return {} @@ -113,18 +113,18 @@ stock_move_scrap() class split_in_production_lot(osv.osv_memory): _name = "stock.move.split" _description = "Split in Production lots" - + _columns = { 'product_id': fields.many2one('product.product', 'Product', required=True, select=True), 'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number') } - + def _get_product_id(self, cr, uid, context): move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) return move.product_id.id - + _defaults = { - 'product_id': _get_product_id, + 'product_id': _get_product_id, } def split_lot(self, cr, uid, ids, context=None): @@ -135,16 +135,15 @@ class split_in_production_lot(osv.osv_memory): prodlot_obj = self.pool.get('stock.production.lot') ir_sequence_obj = self.pool.get('ir.sequence') move_obj = self.pool.get('stock.move') - new_move = [] + new_move = [] for data in self.browse(cr, uid, ids): for move in move_obj.browse(cr, uid, move_ids): move_qty = move.product_qty quantity_rest = move.product_qty uos_qty_rest = move.product_uos_qty - new_move = [] + new_move = [] for line in data.line_ids: quantity = line.quantity - if quantity <= 0 or move_qty == 0: continue @@ -155,52 +154,53 @@ class split_in_production_lot(osv.osv_memory): quantity_rest = quantity break default_val = { - 'product_qty': quantity, - 'product_uos_qty': uos_qty, + 'product_qty': quantity, + 'product_uos_qty': uos_qty, 'state': move.state } + current_move = move_obj.copy(cr, uid, move.id, default_val) new_move.append(current_move) prodlot_id = False if line.use_exist and line.name: prodlot_id = prodlot_obj.search(cr, uid, [('prefix','=',line.name),('product_id','=',data.product_id.id)]) if prodlot_id: - prodlot_id = prodlot_id[0] + prodlot_id = prodlot_id[0] if not prodlot_id: sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') - prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name}, - {'product_id': move.product_id.id}) + prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name}, + {'product_id': move.product_id.id}) move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id}) - prodlot = prodlot_obj.browse(cr, uid, prodlot_id) + prodlot = prodlot_obj.browse(cr, uid, prodlot_id) ref = '%d' % (current_move) if prodlot.ref: - ref = '%s, %s' % (prodlot.ref, ref) + ref = '%s, %s' % (prodlot.ref, ref) prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref}) - + update_val = {} - if quantity_rest > 0: + if quantity_rest > 0: update_val['product_qty'] = quantity_rest - update_val['product_uos_qty'] = uos_qty_rest + update_val['product_uos_qty'] = uos_qty_rest move_obj.write(cr, uid, [move.id], update_val) - + return new_move split_in_production_lot() class stock_move_split_lines(osv.osv_memory): _name = "stock.move.split.lines" _description = "Split lines" - + _columns = { - 'name': fields.char('Tracking serial', size=64), - 'quantity': fields.integer('Quantity'), + 'name': fields.char('Tracking serial', size=64), + 'quantity': fields.integer('Quantity'), 'use_exist' : fields.boolean('Use Exist'), 'lot_id': fields.many2one('stock.move.split', 'Lot'), 'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'), } _defaults = { 'quantity': lambda *x: 1, - 'action' : lambda *x: 'split', + 'action' : lambda *x: 'split', } stock_move_split_lines() diff --git a/addons/stock/stock_wizard.xml b/addons/stock/stock_wizard.xml index 5db1269d42c..d562ddfbb9f 100644 --- a/addons/stock/stock_wizard.xml +++ b/addons/stock/stock_wizard.xml @@ -44,20 +44,6 @@ string="Return picking"/> <wizard - id="wizard_invoice_onshipping" - keyword="client_action_multi" - model="stock.picking" - name="stock.invoice_onshipping" - string="Create invoice"/> - - <wizard - string="Set Stock to 0" - model="stock.inventory" - name="inventory.merge.stock.zero" - keyword="client_action_multi" - id="wizard_merge_inventory_zero"/> - - <wizard string="Merge inventories" model="stock.inventory" name="inventory.merge" @@ -65,19 +51,5 @@ multi="True" id="wizard_merge_inventory"/> - <wizard - string="Fill Inventory" - model="stock.inventory" - name="stock.fill_inventory" - keyword="client_action_multi" - id="wizard_fill_inventory" - /> - - <wizard - id="location_product" - model="stock.location" - name="stock.location.products" - string="Products by Location"/> - - </data> -</openerp> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py index 6a15449a151..c489f880fdf 100644 --- a/addons/stock/wizard/__init__.py +++ b/addons/stock/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -27,12 +27,13 @@ import wizard_replacement import wizard_return import wizard_split_lot_line import wizard_ups -import wizard_invoice_onshipping -import wizard_location_product -import wizard_inventory -import wizard_split_inventory_lots -import inventory_merge_zero import inventory_merge +import stock_inventory_set_stock_zero +import stock_fill_inventory +import stock_inventory_line_split +import stock_invoice_onshipping +import stock_location_product + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/inventory_merge.py b/addons/stock/wizard/inventory_merge.py index 7be8eb2b3e3..b32ad83bec3 100644 --- a/addons/stock/wizard/inventory_merge.py +++ b/addons/stock/wizard/inventory_merge.py @@ -41,6 +41,7 @@ def do_merge(self, cr, uid, data, context): invent_lines = {} if len(data['ids']) < 2: + raise wizard.except_wizard(_('Warning'), _('Please select at least two inventories.')) diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py deleted file mode 100644 index 3aa2b1e9fd9..00000000000 --- a/addons/stock/wizard/inventory_merge_zero.py +++ /dev/null @@ -1,94 +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 -from tools.translate import _ - - -_form = """<?xml version="1.0"?> -<form string="Set Stock to Zero"> - <separator colspan="4" string="Set Stocks to Zero" /> - <field name="location_id"/> - <newline/> - <label colspan="4" string="Do you want to set stocks to zero ?"/> -</form> -""" -_inventory_fields = { - 'location_id' : { - 'string':'Location', - 'type':'many2one', - 'relation':'stock.location', - 'required':True - } -} - - -def do_merge(self, cr, uid, data, context): - invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory') - invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') - prod_obj = pooler.get_pool(cr.dbname).get('product.product') - - if len(data['ids']) <> 1: - raise wizard.except_wizard(_('Warning'), - _('Please select one and only one inventory !')) - - loc = str(data['form']['location_id']) - - cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) - inv = cr.fetchall() - cr.execute('select distinct product_id from stock_move where location_dest_id=%s or location_id=%s',(loc,loc,)) - stock = cr.fetchall() - for s in stock: - if (loc,s[0]) not in inv: - p = prod_obj.browse(cr, uid, s[0]) - invent_line_obj.create(cr, uid, { - 'inventory_id': data['ids'][0], - 'location_id': loc, - 'product_id': s[0], - 'product_uom': p.uom_id.id, - 'product_qty': 0.0, - }) - return {} - - -class merge_inventory(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'form', - 'arch' : _form, - 'fields' : _inventory_fields, - 'state' : [('end', 'Cancel', 'gtk-cancel'), - ('merge', 'Set to Zero', 'gtk-apply', True) ]} - }, - 'merge' : { - 'actions' : [], - 'result' : {'type' : 'action', - 'action': do_merge, - 'state' : 'end'} - }, - } -merge_inventory("inventory.merge.stock.zero") - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py new file mode 100644 index 00000000000..246aff9eabf --- /dev/null +++ b/addons/stock/wizard/stock_fill_inventory.py @@ -0,0 +1,90 @@ +# -*- 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 service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + + +class stock_fill_inventory(osv.osv_memory): + _name = "stock.fill.inventory" + _description = "Fill Inventory" + _columns = { + 'location_id': fields.many2one('stock.location', 'Location', required=True), + 'recursive': fields.boolean("Include all childs for the location"), + } + + def fill_inventory(self, cr, uid, ids, context): + inventory_line_obj = self.pool.get('stock.inventory.line') + location_obj = self.pool.get('stock.location') + for fill_inventory in self.browse(cr, uid, ids): + res = {} + res_location = {} + if fill_inventory.recursive : + location_ids = location_obj.search(cr, uid, [('location_id', + 'child_of', fill_inventory.location_id.id)]) + for location in location_ids : + res = location_obj._product_get(cr, uid, location) + res_location[location] = res + else: + context.update({'compute_child': False}) + res = location_obj._product_get(cr, uid, + fill_inventory.location_id.id, context=context) + res_location[fill_inventory.location_id.id] = res + + product_ids = [] + for location in res_location.keys(): + res = res_location[location] + for product_id in res.keys(): + prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] + uom = prod.uom_id.id + context.update({'uom': uom}) + amount = self.pool.get('stock.location')._product_get(cr, uid, + location, [product_id], context=context)[product_id] + + if(amount): + line_ids=inventory_line_obj.search(cr, uid, + [('inventory_id', '=', context['active_ids']), + ('location_id', '=', location), + ('product_id', '=', product_id), + ('product_uom', '=', uom), + ('product_qty', '=', amount)]) + if not len(line_ids): + inventory_line = {'inventory_id': context['active_ids'][0], + 'location_id': location, + 'product_id': product_id, + 'product_uom': uom, + 'product_qty': amount} + inventory_line_obj.create(cr, uid, inventory_line) + product_ids.append(product_id) + + if(len(product_ids) == 0): + raise osv.except_osv(_('Message !'), _('No product in this location.')) + return {} + +stock_fill_inventory() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_fill_inventory_view.xml b/addons/stock/wizard/stock_fill_inventory_view.xml new file mode 100644 index 00000000000..5ac6732b533 --- /dev/null +++ b/addons/stock/wizard/stock_fill_inventory_view.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_fill_inventory" model="ir.ui.view"> + <field name="name">Fill Inventory</field> + <field name="model">stock.fill.inventory</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Fill Inventory"> + <separator string="Fill Inventory for specific location" colspan="4" /> + <field name="location_id"/> + <newline/> + <field name="recursive"/> + <newline/> + <separator string="" colspan="4" /> + <button special="cancel" string="Cancel" /> + <button name="fill_inventory" string="Fill Inventory" type="object"/> + </form> + </field> + </record> + + <record id="action_view_stock_fill_inventory" model="ir.actions.act_window"> + <field name="name">Fill Inventory</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.fill.inventory</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="wiki_stock_fill_inventory"> + <field name="model_id" ref="stock.model_stock_inventory" /> + <field name="object" eval="1" /> + <field name="name">Fill Inventory</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_stock_fill_inventory'))" /> + <field name="key">action</field> + <field name="model">stock.inventory</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_inventory_line_split.py b/addons/stock/wizard/stock_inventory_line_split.py new file mode 100644 index 00000000000..1723f7b3032 --- /dev/null +++ b/addons/stock/wizard/stock_inventory_line_split.py @@ -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 service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + +class stock_inventory_line_split(osv.osv_memory): + _name = "stock.inventory.line.split" + _description = "Split inventory lines" + _columns = { + 'prefix': fields.char('Prefix', size=64), + 'quantity': fields.float('Quantity per lot'), + } + + def _check_production_lot(self, cr, uid, context): + for inv_obj in self.pool.get('stock.inventory.line').browse(cr, uid, \ + context['active_ids']): + if not inv_obj.prod_lot_id: + raise osv.except_osv(_('Caution!'), _('Before splitting the \ +inventory lines, make sure the production lot is assigned to this product.')) + return + + _defaults = { + 'quantity': lambda *a: '1', + 'prefix': _check_production_lot, + } + + def split_lines(self, cr, uid, ids, context): + inv_id = context['active_id'] + inv_line_obj = self.pool.get('stock.inventory.line') + prodlot_obj = self.pool.get('stock.production.lot') + for linesplit_obj in self.browse(cr, uid, ids): + ir_sequence_obj = self.pool.get('ir.sequence') + + sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') + if not sequence: + raise wizard.except_wizard(_('Error!'), _('No production sequence defined')) + if linesplit_obj.prefix: + sequence = linesplit_obj.prefix + '/' + (sequence or '') + + inv = inv_line_obj.browse(cr, uid, [inv_id])[0] + quantity = linesplit_obj.quantity + prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name': sequence}) + + if quantity <= 0 or inv.product_qty == 0: + return {} + + quantity_rest = inv.product_qty % quantity + + update_val = { + 'product_qty': quantity, + } + + new_line = [] + for idx in range(int(inv.product_qty // quantity)): + if idx: + current_line = inv_line_obj.copy(cr, uid, inv.id, + {'prod_lot_id': inv.prod_lot_id.id}) + new_line.append(current_line) + else: + current_line = inv.id + inv_line_obj.write(cr, uid, [current_line], update_val) + + if quantity_rest > 0: + idx = int(inv.product_qty // quantity) + update_val['product_qty'] = quantity_rest + + if idx: + current_line = inv_line_obj.copy(cr, uid, inv.id, + {'prod_lot_id': inv.prod_lot_id.id}) + new_line.append(current_line) + else: + current_line = inv_line_obj.id + inv_line_obj.write(cr, uid, [current_line], update_val) + + return {} + +stock_inventory_line_split() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/stock/wizard/stock_inventory_line_split_view.xml b/addons/stock/wizard/stock_inventory_line_split_view.xml new file mode 100644 index 00000000000..a2c9f2d065a --- /dev/null +++ b/addons/stock/wizard/stock_inventory_line_split_view.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_inventory_line_split" model="ir.ui.view"> + <field name="name">Split inventory lines</field> + <field name="model">stock.inventory.line.split</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Split Inventory Line"> + <field name="prefix"/> + <newline/> + <field name="quantity"/> + <separator string="" colspan="4" /> + <label string=""/> + <button special="cancel" string="Cancel" icon="gtk-cancel" /> + <button name="split_lines" string="Ok" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <record id="action_view_stock_inventory_line_split" model="ir.actions.act_window"> + <field name="name">Split inventory lines</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.inventory.line.split</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero.py b/addons/stock/wizard/stock_inventory_set_stock_zero.py new file mode 100644 index 00000000000..cfb1d4a0ac9 --- /dev/null +++ b/addons/stock/wizard/stock_inventory_set_stock_zero.py @@ -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 service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + + +class inventory_merge_stock_zero(osv.osv_memory): + _name = "stock.inventory.merge.stock.zero" + _description = "Set Stock to 0" + _columns = { + 'location_id': fields.many2one('stock.location', 'Location', required=True), + } + + def do_merge(self, cr, uid, ids, context): + invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory') + invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') + prod_obj = pooler.get_pool(cr.dbname).get('product.product') + + if len(context['active_ids']) <> 1: + raise wizard.except_wizard(_('Warning'), + _('Please select one and only one inventory !')) + for id in ids: + datas = self.read(cr, uid, id) + loc = str(datas['location_id']) + + cr.execute('select distinct location_id,product_id \ + from stock_inventory_line \ + where inventory_id=%s', (context['active_ids'][0],)) + inv = cr.fetchall() + cr.execute('select distinct product_id from stock_move where \ + location_dest_id=%s or location_id=%s', (loc, loc,)) + stock = cr.fetchall() + for s in stock: + if (loc, s[0]) not in inv: + p = prod_obj.browse(cr, uid, s[0]) + invent_line_obj.create(cr, uid, { + 'inventory_id': context['active_ids'][0], + 'location_id': loc, + 'product_id': s[0], + 'product_uom': p.uom_id.id, + 'product_qty': 0.0, + }) + return {} + +inventory_merge_stock_zero() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml new file mode 100644 index 00000000000..2948b3005ea --- /dev/null +++ b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_inventory_merge_stock_zero" model="ir.ui.view"> + <field name="name">Set Stock to Zero</field> + <field name="model">stock.inventory.merge.stock.zero</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Set Stock to Zero"> + <separator string="Set Stocks to Zero" colspan="4" /> + <field name="location_id"/> + <newline/> + <label colspan="4" string="Do you want to set stocks to zero ?"/> + <separator string="" colspan="4" /> + <button special="cancel" string="Cancel" /> + <button name="do_merge" string="Set Stock to Zero" type="object"/> + </form> + </field> + </record> + + <record id="action_view_inventory_merge_stock_zero" model="ir.actions.act_window"> + <field name="name">Set Stock to Zero</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.inventory.merge.stock.zero</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="wiki_merge_stock_zero"> + <field name="model_id" ref="stock.model_stock_inventory" /> + <field name="object" eval="1" /> + <field name="name">Set Stock to Zero</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_inventory_merge_stock_zero'))" /> + <field name="key">action</field> + <field name="model">stock.inventory</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py new file mode 100644 index 00000000000..82043fc0532 --- /dev/null +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -0,0 +1,111 @@ +# -*- 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 service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + +class stock_invoice_onshipping(osv.osv_memory): + _name = "stock.invoice.onshipping" + _description = "Stock Invoice Onshipping" + _columns = { + 'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True), + 'group': fields.boolean("Group by partner"), + 'type': fields.selection([('out_invoice', 'Customer Invoice'), + ('in_invoice', 'Supplier Invoice'), + ('out_refund', 'Customer Refund'), + ('in_refund', 'Supplier Refund')] , 'Type', required=True), + 'invoice_date': fields.date('Invoiced date'), + } + + def _get_type(self, cr, uid, context): + picking_obj = self.pool.get('stock.picking') + usage = 'customer' + pick = picking_obj.browse(cr, uid, context['active_id']) + if pick.invoice_state == 'invoiced': + raise osv.except_osv(_('UserError'), _('Invoice is already created.')) + if pick.invoice_state == 'none': + raise osv.except_osv(_('UserError'), _('Invoice cannot be created from Picking.')) + if pick.move_lines: + usage = pick.move_lines[0].location_id.usage + + if pick.type == 'out' and usage == 'supplier': + type = 'in_refund' + elif pick.type == 'out' and usage == 'customer': + type = 'out_invoice' + elif pick.type == 'in' and usage == 'supplier': + type = 'in_invoice' + elif pick.type == 'in' and usage == 'customer': + type = 'out_refund' + else: + type = 'out_invoice' + return type + + _defaults = { + 'type': _get_type, + } + + def create_invoice(self, cr, uid, ids, context): + result = [] + for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): + if context.get('new_picking', False): + onshipdata_obj[id] = onshipdata_obj.new_picking + onshipdata_obj[ids] = onshipdata_obj.new_picking + + picking_obj = self.pool.get('stock.picking') + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + + type = onshipdata_obj['type'] + context['date_inv'] = onshipdata_obj['invoice_date'] + res = picking_obj.action_invoice_create(cr, uid,context['active_ids'], + journal_id = onshipdata_obj['journal_id'], + group=onshipdata_obj['group'], + type=type, + context=context) + invoice_ids = res.values() + if not invoice_ids: + raise osv.except_osv(_('Error'), _('Invoice is not created')) + + if type == 'out_invoice': + xml_id = 'action_invoice_tree1' + elif type == 'in_invoice': + xml_id = 'action_invoice_tree2' + elif type == 'out_refund': + xml_id = 'action_invoice_tree3' + else: + xml_id = 'action_invoice_tree4' + + result = mod_obj._get_id(cr, uid, 'account', xml_id) + id = mod_obj.read(cr, uid, result, ['res_id']) + result = act_obj.read(cr, uid, id['res_id']) + result['res_id'] = invoice_ids + return result + +stock_invoice_onshipping() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/stock/wizard/stock_invoice_onshipping_view.xml b/addons/stock/wizard/stock_invoice_onshipping_view.xml new file mode 100644 index 00000000000..c4bec603120 --- /dev/null +++ b/addons/stock/wizard/stock_invoice_onshipping_view.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_invoice_onshipping" model="ir.ui.view"> + <field name="name">Stock Invoice Onshipping</field> + <field name="model">stock.invoice.onshipping</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create invoices"> + <separator colspan="4" string="Create invoices" /> + <field name="journal_id"/> + <newline/> + <field name="group"/> + <newline/> + <field name="type"/> + <newline/> + <field name="invoice_date" /> + <separator string="" colspan="4" /> + <button special="cancel" string="Cancel" /> + <button name="create_invoice" string="Create Invoices" type="object"/> + </form> + </field> + </record> + + <record id="action_stock_invoice_onshipping" model="ir.actions.act_window"> + <field name="name">Create Invoice</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.invoice.onshipping</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="stock_stock_invoice_onshipping"> + <field name="model_id" ref="stock.model_stock_picking" /> + <field name="object" eval="1" /> + <field name="name">Create Invoice</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_stock_invoice_onshipping'))" /> + <field name="key">action</field> + <field name="model">stock.picking</field> + </record> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_location_product.py b/addons/stock/wizard/stock_location_product.py new file mode 100755 index 00000000000..44f6cb4dc7f --- /dev/null +++ b/addons/stock/wizard/stock_location_product.py @@ -0,0 +1,59 @@ +# -*- 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 service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + +class stock_location_product(osv.osv_memory): + _name = "stock.location.product" + _description = "Products by Location" + _columns = { + 'from_date': fields.datetime('From'), + 'to_date': fields.datetime('To'), + } + + def action_open_window(self, cr, uid, ids, context): + mod_obj = self.pool.get('ir.model.data') + for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']): + result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') + id = mod_obj.read(cr, uid, result, ['res_id']) + return { + 'name': 'product', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'product.product', + 'type': 'ir.actions.act_window', + 'context': {'location': context['active_ids'][0], + 'from_date': location_obj['from_date'], + 'to_date': location_obj['to_date']}, + 'domain': [('type', '<>', 'service')], + 'search_view_id': id['res_id'] + } + +stock_location_product() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_location_product_view.xml b/addons/stock/wizard/stock_location_product_view.xml new file mode 100644 index 00000000000..5d54ee874aa --- /dev/null +++ b/addons/stock/wizard/stock_location_product_view.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_location_product" model="ir.ui.view"> + <field name="name">Products by Location</field> + <field name="model">stock.location.product</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="View Stock of Products"> + <separator string="Stock Location Analysis" colspan="4"/> + <field name="from_date" colspan="4"/> + <newline/> + <field name="to_date" colspan="4"/> + <newline/> + <label string=""/> + <label string="(Keep empty to open the current situation. Adjust HH:MM:SS to 00:00:00 to filter all resources of the day for the 'From' date and 23:59:59 for the 'To' date)" align="0.0" colspan="3"/> + <separator string="" colspan="4" /> + <label string=""/> + <button special="cancel" string="Cancel" icon="gtk-cancel" /> + <button name="action_open_window" string="Open Product" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <record id="action_view_stock_location_product" model="ir.actions.act_window"> + <field name="name">Products by Location</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.location.product</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="stock_location_product"> + <field name="model_id" ref="stock.model_stock_location" /> + <field name="object" eval="1" /> + <field name="name">Products by Location</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_stock_location_product'))" /> + <field name="key">action</field> + <field name="model">stock.location</field> + </record> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_traceability.py b/addons/stock/wizard/stock_traceability.py index 58cc26a3224..3fc65ff74c0 100644 --- a/addons/stock/wizard/stock_traceability.py +++ b/addons/stock/wizard/stock_traceability.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## diff --git a/addons/stock/wizard/wizard_inventory.py b/addons/stock/wizard/wizard_inventory.py deleted file mode 100644 index 42345353866..00000000000 --- a/addons/stock/wizard/wizard_inventory.py +++ /dev/null @@ -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 time -import wizard -import ir -import pooler -from osv.osv import except_osv -from osv import fields,osv -import netsvc -from tools.translate import _ - -inventory_form = """<?xml version="1.0"?> -<form string="Fill Inventory"> - <separator colspan="4" string="Fill Inventory for specific location" /> - <field name="location_id"/> - <newline/> - <field name="recursive"/> - <newline/> - -</form> -""" - -inventory_fields = { - 'location_id' : { - 'string':'Location', - 'type':'many2one', - 'relation':'stock.location', - 'required':True - }, - 'recursive' : {'string':'Include all childs for the location', 'type':'boolean'} -} - - - -def _fill_inventory(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - inventory_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') - location_obj = pooler.get_pool(cr.dbname).get('stock.location') - res={} - res_location={} - if data['form']['recursive'] : - location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', [data['form']['location_id']])]) - for location in location_ids : - res=location_obj._product_get(cr, uid, location) - res_location[location]=res - else: - context.update({'compute_child':False}) - res=location_obj._product_get(cr, uid, data['form']['location_id'],context=context) - res_location[data['form']['location_id']]=res - - product_ids=[] - for location in res_location.keys(): - res=res_location[location] - for product_id in res.keys(): - #product_ids.append(product_id) - prod = pool.get('product.product').browse(cr, uid, [product_id])[0] - uom = prod.uom_id.id - context.update({'uom': uom}) - amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], context=context)[product_id] - - if(amount): - line_ids=inventory_line_obj.search(cr,uid,[('inventory_id','=',data['id']),('location_id','=',location),('product_id','=',product_id),('product_uom','=',uom),('product_qty','=',amount)]) - if not len(line_ids): - inventory_line={'inventory_id':data['id'],'location_id':location,'product_id':product_id,'product_uom':uom,'product_qty':amount} - inventory_line_obj.create(cr, uid, inventory_line) - product_ids.append(product_id) - - if(len(product_ids)==0): - raise wizard.except_wizard(_('Message !'), _('No product in this location.')) - return {} - - - -class fill_inventory(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'form', - 'arch' : inventory_form, - 'fields' : inventory_fields, - 'state' : [('end', 'Cancel', 'gtk-cancel'),('fill_inventory', 'Fill Inventory', 'gtk-apply', True) ]} - }, - 'fill_inventory' : { - 'actions' : [], - 'result' : {'type' : 'action', 'action': _fill_inventory, 'state' : 'end'} - }, - } -fill_inventory("stock.fill_inventory") - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/wizard_invoice_onshipping.py b/addons/stock/wizard/wizard_invoice_onshipping.py deleted file mode 100644 index 22cdbc97e70..00000000000 --- a/addons/stock/wizard/wizard_invoice_onshipping.py +++ /dev/null @@ -1,167 +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 -from tools.translate import _ - -invoice_form = """<?xml version="1.0"?> -<form string="Create invoices"> - <separator colspan="4" string="Create invoices" /> - <field name="journal_id"/> - <newline/> - <field name="group"/> - <newline/> - <field name="type"/> - <newline/> - <field name="invoice_date" /> -</form> -""" - -invoice_fields = { - 'journal_id': { - 'string': 'Destination Journal', - 'type': 'many2one', - 'relation': 'account.journal', - 'required': True - }, - 'group': { - 'string': 'Group by partner', - 'type': 'boolean' - }, - 'type': { - 'string': 'Type', - 'type': 'selection', - 'selection': [], - 'required': True - }, - 'invoice_date': {'string': 'Invoiced date', 'type':'date' } -} - - -def _get_type(obj, cr, uid, data, context): - picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') - usage = 'customer' - pick = picking_obj.browse(cr, uid, data['id'], context) - if pick.invoice_state == 'invoiced': - raise wizard.except_wizard(_('UserError'), _('Invoice is already created.')) - if pick.invoice_state == 'none': - raise wizard.except_wizard(_('UserError'), _('Invoice cannot be created from Picking.')) - - if pick.move_lines: - usage = pick.move_lines[0].location_id.usage - - if pick.type =='out': - invoice_fields['type']['selection'] = [ - ('out_invoice', 'Customer Invoice'), - ('in_refund', 'Supplier Refund'), - ] - elif pick.type =='in': - invoice_fields['type']['selection'] = [ - ('in_invoice', 'Supplier Invoice'), - ('out_refund', 'Customer Refund'), - ] - else: - invoice_fields['type']['selection']=[ - ('out_invoice', 'Customer Invoice'), - ('in_invoice', 'Supplier Invoice'), - ('out_refund', 'Customer Refund'), - ('in_refund', 'Supplier Refund'), - ] - - if pick.type == 'out' and usage == 'supplier': - type = 'in_refund' - elif pick.type == 'out' and usage == 'customer': - type = 'out_invoice' - elif pick.type == 'in' and usage == 'supplier': - type = 'in_invoice' - elif pick.type == 'in' and usage == 'customer': - type = 'out_refund' - else: - type = 'out_invoice' - return {'type': type} - - -def _create_invoice(obj, cr, uid, data, context): - if data['form'].get('new_picking', False): - data['id'] = data['form']['new_picking'] - data['ids'] = [data['form']['new_picking']] - pool = pooler.get_pool(cr.dbname) - picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') - mod_obj = pool.get('ir.model.data') - act_obj = pool.get('ir.actions.act_window') - - type = data['form']['type'] - - context['date_inv'] = data['form']['invoice_date'] - res = picking_obj.action_invoice_create(cr, uid, data['ids'], - journal_id = data['form']['journal_id'], group=data['form']['group'], - type=type, context= context) - - invoice_ids = res.values() - if not invoice_ids: - raise wizard.except_wizard(_('Error'), _('Invoice is not created')) - - if type == 'out_invoice': - xml_id = 'action_invoice_tree1' - elif type == 'in_invoice': - xml_id = 'action_invoice_tree2' - elif type == 'out_refund': - xml_id = 'action_invoice_tree3' - else: - xml_id = 'action_invoice_tree4' - - result = mod_obj._get_id(cr, uid, 'account', xml_id) - id = mod_obj.read(cr, uid, result, ['res_id']) - result = act_obj.read(cr, uid, id['res_id']) - result['res_id'] = invoice_ids - return result - - -class make_invoice_onshipping(wizard.interface): - states = { - 'init': { - 'actions': [_get_type], - 'result': { - 'type': 'form', - 'arch': invoice_form, - 'fields': invoice_fields, - 'state': [ - ('end', 'Cancel', 'gtk-cancel'), - ('create_invoice', 'Create invoice', 'gtk-apply', True) - ] - } - }, - 'create_invoice': { - 'actions': [], - 'result': { - 'type': 'action', - 'action': _create_invoice, - 'state': 'end' - } - }, - } - -make_invoice_onshipping("stock.invoice_onshipping") - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/wizard/wizard_location_product.py b/addons/stock/wizard/wizard_location_product.py deleted file mode 100755 index c423c426832..00000000000 --- a/addons/stock/wizard/wizard_location_product.py +++ /dev/null @@ -1,76 +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 - -def _action_open_window(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.model.data') - result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') - id = mod_obj.read(cr, uid, result, ['res_id']) - return { - 'name': False, - 'view_type': 'form', - "view_mode": 'tree,form', - 'res_model': 'product.product', - 'type': 'ir.actions.act_window', - 'context':{'location': data['ids'][0],'from_date':data['form']['from_date'],'to_date':data['form']['to_date']}, - 'domain':[('type','<>','service')], - 'search_view_id': id['res_id'] - } - - -class product_by_location(wizard.interface): - form1 = '''<?xml version="1.0"?> - <form string="View Stock of Products"> - <separator string="Stock Location Analysis" colspan="4"/> - <field name="from_date"/> - <newline/> - <field name="to_date"/> - <newline/> - <label string=""/> - <label string="(Keep empty to open the current situation. Adjust HH:MM:SS to 00:00:00 to filter all resources of the day for the 'From' date and 23:59:59 for the 'To' date)" align="0.0" colspan="3"/> - </form>''' - form1_fields = { - 'from_date': { - 'string': 'From', - 'type': 'datetime', - }, - 'to_date': { - 'string': 'To', - 'type': 'datetime', - }, - } - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel', 'gtk-cancel'),('open', 'Open Products', 'gtk-apply', True)]} - }, - 'open': { - 'actions': [], - 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'} - } - } -product_by_location('stock.location.products') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/wizard_split_inventory_lots.py b/addons/stock/wizard/wizard_split_inventory_lots.py deleted file mode 100644 index 92963f0b145..00000000000 --- a/addons/stock/wizard/wizard_split_inventory_lots.py +++ /dev/null @@ -1,98 +0,0 @@ -import wizard -import netsvc -import pooler - -import time -from osv import osv -from tools.translate import _ - -inv_form = '''<?xml version="1.0"?> -<form string="Split Inventory Line"> - <field name="prefix"/> - <newline/> - <field name="quantity"/> -</form> -''' -inv_fields = { - 'prefix': { - 'string': 'Prefix', - 'type': 'char', - 'size': 64, - }, - 'quantity': { - 'string': 'Quantity per lot', - 'type': 'float', - 'default': 1, - } -} - -def _check_production_lot(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - inv_obj = pool.get('stock.inventory.line').browse(cr, uid, data['id']) - if not inv_obj.prod_lot_id: - raise wizard.except_wizard(_('Caution!'), _('Before splitting the inventory lines, make sure the production lot is assigned to this product.')) - return data['form'] - -def _split_lines(self, cr, uid, data, context): - inv_id = data['id'] - - pool = pooler.get_pool(cr.dbname) - inv_line_obj = pool.get('stock.inventory.line') - prodlot_obj = pool.get('stock.production.lot') - - ir_sequence_obj = pool.get('ir.sequence') - - sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') - if not sequence: - raise wizard.except_wizard(_('Error!'), _('No production sequence defined')) - if data['form']['prefix']: - sequence=data['form']['prefix']+'/'+(sequence or '') - - inv = inv_line_obj.browse(cr, uid, [inv_id])[0] - quantity=data['form']['quantity'] - prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name':sequence}) - - if quantity <= 0 or inv.product_qty == 0: - return {} - - quantity_rest = inv.product_qty%quantity - - update_val = { - 'product_qty': quantity, - } - - new_line = [] - for idx in range(int(inv.product_qty//quantity)): - if idx: - current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id}) - new_line.append(current_line) - else: - current_line = inv.id - inv_line_obj.write(cr, uid, [current_line], update_val) - - if quantity_rest > 0: - idx = int(inv.product_qty//quantity) - update_val['product_qty']=quantity_rest - - if idx: - current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id}) - new_line.append(current_line) - else: - current_line = inv.id - inv_line_obj.write(cr, uid, [current_line], update_val) - - return {} - -class wizard_split_inventory_lots(wizard.interface): - states = { - 'init': { - 'actions': [_check_production_lot], - 'result': {'type': 'form', 'arch': inv_form, 'fields': inv_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('split', 'Ok', 'gtk-apply', True)]}, - }, - 'split': { - 'actions': [_split_lines], - 'result': {'type':'state', 'state':'end'} - } - } - -wizard_split_inventory_lots('stock.inventory.line.split')
\ No newline at end of file diff --git a/addons/wiki/__terp__.py b/addons/wiki/__terp__.py index cf792be226f..b15346dba39 100644 --- a/addons/wiki/__terp__.py +++ b/addons/wiki/__terp__.py @@ -33,10 +33,14 @@ 'depends': ['base'], 'init_xml': [], 'update_xml': [ + 'wizard/wizard_view.xml', + 'wizard/wiki_wiki_page_open_view.xml', + 'wizard/wiki_create_menu_view.xml', + 'wizard/wiki_wiki_help_open_view.xml', + 'wizard/wiki_make_index_view.xml', 'wiki_view.xml', 'data/wiki_quickstart.xml', 'data/wiki_main.xml', - 'wizard/wizard_view.xml', 'security/ir.model.access.csv' ], 'demo_xml': [], diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml index d2fa06d4fd5..e6feae5eeba 100644 --- a/addons/wiki/wiki_view.xml +++ b/addons/wiki/wiki_view.xml @@ -6,7 +6,7 @@ <menuitem name="Wiki" id="menu_wiki_configuration" parent="base.menu_document_configuration" sequence="2"/> <menuitem id="base.menu_document2" name="Collaborative Content" parent="base.menu_document"/> - <wizard + <wizard id="wizard_group_menu_create" string="Create Menu" menu="True" @@ -49,11 +49,16 @@ <field name="template" colspan="4" nolabel="1" widget="text_wiki"/> </page> </notebook> - <button - name="%(wizard_group_menu_create)d" - string="Create a Menu" - type="action" - target="new" icon="gtk-justify-fill"/> + <button + name="%(wiki.action_wiki_create_menu)d" + string="Create Menu" + type="action" + icon="gtk-justify-fill" /> + <button + name="%(wiki.action_view_wiki_wiki_page_open)d" + string="Open Wiki Page" + type="action"/> + </form> </field> </record> @@ -137,6 +142,14 @@ <field name="tags" select="1" groups="base.group_extended"/> <field name="summary" colspan="4" select="2" groups="base.group_extended"/> </group> + <button + name="%(wiki.action_view_wiki_wiki_help_open)d" + string="Basic Wiki Editing" + type="action"/> + <button + name="%(wiki.action_view_wiki_make_index)d" + string="Create Index" + type="action"/> </form> </field> </record> @@ -234,7 +247,7 @@ res_model="wiki.wiki" src_model="wiki.groups"/> - <wizard + <wizard id="wizard_open_page" string="Open Wiki Pages" name="wiki.wiki.page.open" diff --git a/addons/wiki/wizard/__init__.py b/addons/wiki/wizard/__init__.py index 1777b053bca..13caf0b9216 100644 --- a/addons/wiki/wizard/__init__.py +++ b/addons/wiki/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,13 +15,13 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -import open_page -import open_help -import create_menu -import show_diff -import make_index +import wiki_wiki_page_open +import wiki_create_menu +import wiki_wiki_help_open +import wiki_make_index + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wizard/create_menu.py b/addons/wiki/wizard/create_menu.py deleted file mode 100644 index e31a9daa664..00000000000 --- a/addons/wiki/wizard/create_menu.py +++ /dev/null @@ -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 time -import wizard -import osv -import pooler - -section_form = '''<?xml version="1.0"?> -<form string="Create Menu"> - <separator string="Menu Information" colspan="4"/> - <field name="menu_name"/> - <field name="menu_parent_id"/> - <field name="page" colspan="4"/> -</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}, - 'page': {'string':'Group Home Page', 'type':'many2one', 'relation':'wiki.wiki'}, -} - -def wiki_menu_create(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - group = pool.get('wiki.groups').browse(cr, uid, data['id']) - action_id = pool.get('ir.actions.wizard').search(cr, uid, [('wiz_name','=','wiki.wiki.page.open')]) - - menu_id = pool.get('ir.ui.menu').create(cr, uid, { - 'name': data['form']['menu_name'], - 'parent_id': data['form']['menu_parent_id'], - 'icon': 'STOCK_DIALOG_QUESTION', - 'action': 'ir.actions.wizard,'+str(action_id[0]) - }, context) - - home = data['form']['page'] - group_id = data['id'] - res = { - 'home':home, - } - pool.get('wiki.groups').write(cr, uid, [data['id']], res) - pool.get('wiki.groups.link').create(cr, uid, {'group_id':group_id, 'action_id':menu_id}) - - return {} - -class wizard_create_menu(wizard.interface): - states = { - 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]} - }, - 'create_menu': { - 'actions': [wiki_menu_create], - 'result': { - 'type':'state', - 'state':'end' - } - } - } -wizard_create_menu('wiki.create.menu') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wizard/make_index.py b/addons/wiki/wizard/make_index.py deleted file mode 100644 index 09a3b5de4ac..00000000000 --- a/addons/wiki/wizard/make_index.py +++ /dev/null @@ -1,98 +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 time -import wizard -import osv -import pooler - -section_form = '''<?xml version="1.0"?> -<form string="Create Menu"> - <separator string="Menu Information" colspan="4"/> - <label string="Want to create a Index on Selected Pages ? "/> -</form>''' - -def wiki_do_index(self, cr, uid, data, context): - ids = data['ids'] - pool = pooler.get_pool(cr.dbname) - wiki_pool = pool.get('wiki.wiki') - cr.execute("Select id, section from wiki_wiki where id = ANY(%s) order by section " ,(ids,)) - lst0 = cr.fetchall() - lst = [] - ids = {} - for l in lst0: - ids[l[1]] = l[0] - lst.append(l[1]) - - lst.sort() - val = None - def toint(x): - try: - return int(x) - except: - return 1 - - lst = map(lambda x: map(toint, x.split('.')), lst) - - result = [] - current = ['0'] - current2 = [] - - for l in lst: - for pos in range(len(l)): - if pos >= len(current): - current.append('1') - continue - if (pos == len(l) - 1) or (pos >= len(current2)) or (toint(l[pos]) > toint(current2[pos])): - current[pos] = str(toint(current[pos]) + 1) - current = current[:pos + 1] - if pos == len(l) - 1: - break - - key = ('.'.join([str(x) for x in l])) - id = ids[key] - val = ('.'.join([str(x) for x in current[:]]), id) - - if val: - result.append(val) - current2 = l - - for rs in result: - wiki_pool.write(cr, uid, [rs[1]], {'section':rs[0]}) - return {} - -class make_index(wizard.interface): - states = { - 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':section_form, 'fields':{}, 'state':[('end','Cancel'),('yes','Create Index')]} - }, - 'yes': { - 'actions': [wiki_do_index], - 'result': { - 'type':'state', - 'state':'end' - } - } - } -make_index('wiki.make.index') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wizard/wiki_create_menu.py b/addons/wiki/wizard/wiki_create_menu.py new file mode 100644 index 00000000000..352e9e78a4c --- /dev/null +++ b/addons/wiki/wizard/wiki_create_menu.py @@ -0,0 +1,65 @@ +# -*- 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 osv import fields, osv +from service import web_services +import pooler +import time +import wizard + +class wiki_create_menu(osv.osv_memory): + _name = "wiki.create.menu" + _description = "Wizard Create Menu" + _columns = { + 'menu_name': fields.char('Menu Name', size=256, select=True, required=True), + 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True), + 'page': fields.many2one('wiki.wiki', 'Group Home Page'), + } + + def wiki_menu_create(self, cr, uid, ids, context): + """ Create Menu On the base of Group id and Action id """ + + for group in self.pool.get('wiki.groups').browse(cr, uid, ids): + for menu in self.pool.get('wiki.create.menu').browse(cr, uid, ids): + + mod_obj = self.pool.get('ir.model.data') + action_id = mod_obj._get_id(cr, uid, 'wiki', 'action_view_wiki_wiki_page_open') + menu_id = self.pool.get('ir.ui.menu').create(cr, uid, { + 'name':menu.menu_name, + 'parent_id':menu.menu_parent_id.id, + 'icon': 'STOCK_DIALOG_QUESTION', + 'action': 'ir.actions.act_window,'+ str(action_id) + }, context) + home = menu.page.id + group_id = menu.id + res = { + 'home':home, + } + self.pool.get('wiki.groups').write(cr, uid, ids, res) + self.pool.get('wiki.groups.link').create(cr, uid, + {'group_id': group_id, 'action_id':menu_id}) + + return {} + +wiki_create_menu() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/addons/wiki/wizard/wiki_create_menu_view.xml b/addons/wiki/wizard/wiki_create_menu_view.xml new file mode 100644 index 00000000000..7acd1e2a70d --- /dev/null +++ b/addons/wiki/wizard/wiki_create_menu_view.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_wiki_create_menu" model="ir.ui.view"> + <field name="name">Create Menu</field> + <field name="model">wiki.create.menu</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create Menu"> + <separator string="Menu Information" colspan="4" /> + <field name="menu_name" /> + <field name="menu_parent_id" /> + <field name="page" colspan="4" /> + <separator string="" colspan="4" /> + <label string="" colspan="2" /> + <button special="cancel" string="Cancel" /> + <button name="wiki_menu_create" string="Create Menu" type="object"/> + </form> + </field> + </record> + + <record id="action_wiki_create_menu" model="ir.actions.act_window"> + <field name="name">Create Menu</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.create.menu</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/wiki/wizard/wiki_make_index.py b/addons/wiki/wizard/wiki_make_index.py new file mode 100644 index 00000000000..56980c5288e --- /dev/null +++ b/addons/wiki/wizard/wiki_make_index.py @@ -0,0 +1,86 @@ +# -*- 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 service import web_services +import time +import wizard +import pooler + +class wiki_make_index(osv.osv_memory): + _name = "wiki.make.index" + _description = "Create Index" + _columns = { + } + + def wiki_do_index(self, cr, uid, ids, context): + """ Makes Index according to page hierarchy""" + for index_obj in self.browse(cr,uid,ids): + wiki_pool = self.pool.get('wiki.wiki') + cr.execute("Select id, section from wiki_wiki where id = ANY(%s) \ + order by section " ,(context['active_ids'],)) + lst0 = cr.fetchall() + lst = [] + s_ids = {} + for l in lst0: + s_ids[l[1]] = l[0] + lst.append(l[1]) + + lst.sort() + val = None + def toint(x): + try: + return int(x) + except: + return 1 + + lst = map(lambda x: map(toint, x.split('.')), lst) + + result = [] + current = ['0'] + current2 = [] + + for l in lst: + for pos in range(len(l)): + if pos >= len(current): + current.append('1') + continue + if (pos == len(l) - 1) or (pos >= len(current2)) or (toint(l[pos]) > toint(current2[pos])): + current[pos] = str(toint(current[pos]) + 1) + current = current[:pos + 1] + if pos == len(l) - 1: + break + + key = ('.'.join([str(x) for x in l])) + id = s_ids[key] + val = ('.'.join([str(x) for x in current[:]]), id) + + if val: + result.append(val) + current2 = l + + for rs in result: + wiki_pool.write(cr, uid, [rs[1]], {'section':rs[0]}) + return {} + +wiki_make_index() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wizard/wiki_make_index_view.xml b/addons/wiki/wizard/wiki_make_index_view.xml new file mode 100644 index 00000000000..fcba8909f5f --- /dev/null +++ b/addons/wiki/wizard/wiki_make_index_view.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_wiki_make_index" model="ir.ui.view"> + <field name="name">Create Index</field> + <field name="model">wiki.make.index</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create Menu"> + <separator string="Menu Information" colspan="4"/> + <label string="Want to create a Index on Selected Pages ? "/> + <separator string="" colspan="4" /> + <label string="" colspan="2" /> + <button special="cancel" string="Cancel" /> + <button name="wiki_do_index" string="Create Index" type="object"/> + </form> + </field> + </record> + + <record id="action_view_wiki_make_index" model="ir.actions.act_window"> + <field name="name">Create Index</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.make.index</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/wiki/wizard/open_help.py b/addons/wiki/wizard/wiki_wiki_help_open.py index 6be88349a81..933aa54f7cd 100644 --- a/addons/wiki/wizard/open_help.py +++ b/addons/wiki/wizard/wiki_wiki_help_open.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # @@ -20,22 +20,22 @@ # ############################################################################## - -import wizard -import netsvc +from osv import fields, osv +from service import web_services import time +import wizard import pooler -from osv import osv -from tools.translate import _ -class wiz_open_help(wizard.interface): - - def _open_wiki_page(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - pages = pool.get('wiki.wiki').search(cr, uid, [('name','=','Basic Wiki Editing')]) - +class wiki_wiki_help_open(osv.osv_memory): + _name = "wiki.wiki.help.open" + _description = "Basic Wiki Editing" + _columns = { + } + def _open_wiki_page(self, cr, uid, ids, context): + """ Opens Wiki Page for Editing""" + pages = self.pool.get('wiki.wiki').search(cr, uid, [('name','=','Basic Wiki Editing')]) + value = { - 'name': 'Basic Wiki Editing', 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'wiki.wiki', @@ -43,16 +43,10 @@ class wiz_open_help(wizard.interface): 'res_id': pages[0], 'type': 'ir.actions.act_window', } - + return value - states = { - 'init' : { - 'actions' : [], - 'result' : {'type':'action', 'action':_open_wiki_page, 'state':'end'} - } - } -wiz_open_help('wiki.wiki.help.open') +wiki_wiki_help_open() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wizard/wiki_wiki_help_open_view.xml b/addons/wiki/wizard/wiki_wiki_help_open_view.xml new file mode 100644 index 00000000000..2f525443900 --- /dev/null +++ b/addons/wiki/wizard/wiki_wiki_help_open_view.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_wiki_wiki_help_open" model="ir.ui.view"> + <field name="name">Basic Wiki Editing</field> + <field name="model">wiki.wiki.help.open</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Open Help"> + <separator string="" colspan="6" /> + <label string="" colspan="2" /> + <button name="_open_wiki_page" string="Basic Wiki Editing" type="object"/> + </form> + </field> + </record> + + <record id="action_view_wiki_wiki_help_open" model="ir.actions.act_window"> + <field name="name">Basic Wiki Editing</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.wiki.help.open</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/wiki/wizard/open_page.py b/addons/wiki/wizard/wiki_wiki_page_open.py index df015f5c5a0..4102e6486dd 100644 --- a/addons/wiki/wizard/open_page.py +++ b/addons/wiki/wizard/wiki_wiki_page_open.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,33 +15,36 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## - -import wizard -import netsvc +from osv import fields, osv +from service import web_services import time +import wizard import pooler -from osv import osv -from tools.translate import _ -class wiz_open_page(wizard.interface): - - def _open_wiki_page(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - group = pool.get('wiki.groups').browse(cr, uid, data['id']) - - value = { - 'context': "{'group_id':%d, 'section':%s}" % (group.id, group.section), - 'domain': "[('group_id','=',%d)]" % (group.id), - 'name': 'Wiki Page', - 'view_type': 'form', - 'view_mode': 'form,tree', - 'res_model': 'wiki.wiki', - 'view_id': False, - 'type': 'ir.actions.act_window', +class wiki_wiki_page_open(osv.osv_memory): + _name = "wiki.wiki.page.open" + _description = "wiz open page" + _columns = { + + } + def _open_wiki_page(self, cr, uid, ids, context): + """ Opens Wiki Page of Group""" + for group in self.pool.get('wiki.groups').browse(cr, uid,ids): + + for openpage in self.pool.get('wiki.wiki.page.open').browse(cr, uid,ids): + + value = { + 'domain': "[('group_id','=',%d)]" % (group.id), + 'name': 'Wiki Page', + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': 'wiki.wiki', + 'view_id': False, + 'type': 'ir.actions.act_window', } if group.method == 'page': value['res_id'] = group.home.id @@ -52,17 +55,10 @@ class wiz_open_page(wizard.interface): view_id = pool.get('ir.ui.view').search(cr, uid, [('name','=','wiki.wiki.tree.childs')]) value['view_id'] = view_id value['domain'] = [('group_id','=',group.id),('parent_id','=',False)] - value['view_type'] = 'tree' + value['view_type'] = 'tree' return value - states = { - 'init' : { - 'actions' : [], - 'result' : {'type':'action', 'action':_open_wiki_page, 'state':'end'} - } - } -wiz_open_page('wiki.wiki.page.open') - +wiki_wiki_page_open() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wizard/wiki_wiki_page_open_view.xml b/addons/wiki/wizard/wiki_wiki_page_open_view.xml new file mode 100644 index 00000000000..7e21f868d6e --- /dev/null +++ b/addons/wiki/wizard/wiki_wiki_page_open_view.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_wiki_wiki_page_open" model="ir.ui.view"> + <field name="name">Open Page</field> + <field name="model">wiki.wiki.page.open</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Open Page"> + <separator string="" colspan="6" /> + <label string="" colspan="2" /> + <button name="_open_wiki_page" string="Open Wiki Page" type="object"/> + </form> + </field> + </record> + + <record id="action_view_wiki_wiki_page_open" model="ir.actions.act_window"> + <field name="name">Open Page</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.wiki.page.open</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + </data> +</openerp> diff --git a/addons/wiki/wizard/wizard_view.xml b/addons/wiki/wizard/wizard_view.xml index cbc5f020731..ce639714daf 100644 --- a/addons/wiki/wizard/wizard_view.xml +++ b/addons/wiki/wizard/wizard_view.xml @@ -13,18 +13,18 @@ </field> </record> <act_window - id="act_view_diff" - name="Differences" - res_model="wizard.wiki.history.show_diff" + id="act_view_diff" + name="Differences" + res_model="wizard.wiki.history.show_diff" src_model="wiki.wiki.history" target="new" view_mode="form" /> -<!-- <wizard + <wizard id="wizard_make_index" string="Create Index" name="wiki.make.index" - model="wiki.wiki"/--> + model="wiki.wiki"/> <wizard id="wizard_open_help" string="Basic Wiki Editing" diff --git a/addons/wiki/wizard/wizard_wiki.py b/addons/wiki/wizard/wizard_wiki.py new file mode 100644 index 00000000000..9113b0a1b72 --- /dev/null +++ b/addons/wiki/wizard/wizard_wiki.py @@ -0,0 +1,142 @@ +# -*- 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 service import web_services +import time +import wizard +import pooler + + +class wizard_create_menu(osv.osv_memory): + _name = "wiki.wizard.create.menu" + _description="Wiki.Wizard Create Menu" + _columns={ + 'menu_name':fields.char('Menu Name', size=256, select=True, required=True), + 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True), + 'page': fields.many2one('wiki.wiki', 'Group Home Page'), + } + + def wiki_menu_create(self, cr, uid, ids, context): + group = self.pool.get('wiki.groups').browse(cr, uid, ids)[0] + menu = self.pool.get('wiki.wizard.create.menu').browse(cr, uid, ids)[0] + action_id = self.pool.get('').search(cr, uid, [('wiz_name', '=', 'wiki.wiki.page.open')]) + + menu_id = self.pool.get('ir.ui.menu').create(cr, uid, { + 'name':menu.menu_name, + 'parent_id':menu.menu_parent_id.id, + 'icon': 'STOCK_DIALOG_QUESTION', + 'action': 'ir.actions.wizard,'+str(action_id[0]) + }, context) + + home = menu.page.id + group_id = menu.id + res = { + 'home':home, + } + self.pool.get('wiki.groups').write(cr, uid, ids, res) + self.pool.get('wiki.groups.link').create(cr, uid, {'group_id':group_id, 'action_id':menu_id}) + + return {} + + +wizard_create_menu() + +class wiz_open_help(osv.osv_memory): + _name = "wiki.wiz.open.help" + _description="Wiki Open Help" + _columns={ + 'name':fields.char('Basic Wiki Editing', size=256, select=True, required=False), + + } + def _open_wiki_page(self, cr, uid, ids, context): + pages = self.pool.get('wiki.wiki').search(cr, uid, [('name', '=', 'Basic Wiki Editing')]) + + value = { + 'view_id': False, + 'res_id': pages[0], + } + + return value + +wiz_open_help() + +class wiz_open_page(osv.osv_memory): + _name = "wiki.wiz.open.page" + _description="wiz open page" + _columns={ + 'name':fields.char('Wiki Page', size=256, select=True, required=False), + + } + def _open_wiki_page(self, cr, uid, ids, context): + group = self.pool.get('wiki.groups').browse(cr, uid, ids)[0] + openpage = self.pool.get('wiki.wiz.open.page').browse(cr, uid, ids)[0] + + value = { + 'context': "{'group_id':%d, 'section':%s}" % (group.id, group.section), + 'domain': "[('group_id','=',%d)]" % (group.id), + 'type': 'ir.actions.act_window', + } + if group.method == 'page': + value['res_id'] = group.home.id + elif group.method == 'list': + value['view_type'] = 'form' + value['view_mode'] = 'tree,form' + elif group.method == 'tree': + view_id = pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'wiki.wiki.tree.childs')]) + value['view_id'] = view_id + value['domain'] = [('group_id', '=', group.id), ('parent_id', '=', False)] + value['view_type'] = 'tree' + + return value +wiz_open_page() + +class showdiff(osv.osv_memory): + _name = 'wizard.wiki.history.show_diff' + + def _get_diff(self, cr, uid, ctx): + history = self.pool.get('wiki.wiki.history') + ids = ctx.get('active_ids') + diff = "" + if len(ids) == 2: + if ids[0] > ids[1]: + diff = history.getDiff(cr, uid, ids[1], ids[0]) + else: + diff = history.getDiff(cr, uid, ids[0], ids[1]) + + elif len(ids) == 1: + old = history.browse(cr, uid, ids[0]) + nids = history.search(cr, uid, [('wiki_id', '=', old.wiki_id.id)]) + nids.sort() + diff = history.getDiff(cr, uid, ids[0], nids[-1]) + else: + raise osv.except_osv(_('Warning'), _('You need to select minimum 1 or maximum 2 history revision!')) + return diff + + _columns = { + 'diff': fields.text('Diff'), + } + _defaults = { + 'diff': _get_diff + } + +showdiff() + diff --git a/addons/wiki/wizard/wizard_wiki.xml b/addons/wiki/wizard/wizard_wiki.xml new file mode 100644 index 00000000000..8125836d8bf --- /dev/null +++ b/addons/wiki/wizard/wizard_wiki.xml @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <!-- correct indentation --> + + <record id="view_wizard_create_menu" model="ir.ui.view"> + <field name="name">Create Menu</field> + <field name="model">wiki.wizard.create.menu</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create Menu"> + <separator string="Menu Information" colspan="4" /> + <field name="menu_name" /> + <field name="menu_parent_id" /> + <field name="page" colspan="4" /> + <separator string="" colspan="4" /> + <label string="" colspan="2" /> + <button special="cancel" string="Cancel" /> + <button name="wiki_menu_create" string="Create Menu" type="object"/> + </form> + </field> + </record> + + <record id="wizard_group_menu_create" model="ir.actions.act_window"> + <field name="name">Create Menu</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.wizard.create.menu</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <!-- ==========================open help =========================--> + + <record id="view_wiz_open_help" model="ir.ui.view"> + <field name="name">Open Help</field> + <field name="model">wiki.wiz.open.help</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Open Help"> + <field name="name" /> + <separator string="" colspan="6" /> + <label string="" colspan="2" /> + </form> + </field> + </record> + + <record id="wizard_open_help" model="ir.actions.act_window"> + <field name="name">Open Help</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.wiki</field> + <field name="view_type">form</field> + <field name="view_mode">form,tree</field> + <field name="target">new</field> + </record> + <!-- ==========================Open Page =========================--> + + <record id="view_wiz_open_page" model="ir.ui.view"> + <field name="name">Open Page</field> + <field name="model">wiki.wiz.open.page</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Open Page"> + <field name="name" /> + <separator string="" colspan="6" /> + <label string="" colspan="2" /> + </form> + </field> + </record> + + <record id="wizard_open_page" model="ir.actions.act_window"> + <field name="name">Open Page</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wiki.wiki</field> + <field name="view_type">form</field> + <field name="view_mode">form,tree</field> + <field name="target">new</field> + </record> + + + <record id="view_wiki_history_diff" model="ir.ui.view"> + <field name="name">Differences</field> + <field name="model">wizard.wiki.history.show_diff</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="History Differance"> + <separator string="Wiki Differance" colspan="4"/> + <field name="diff" widget="text_html" nolabel="1" colspan="4"/> + </form> + </field> + </record> + + <act_window + id="act_view_diff" + name="Differences" + res_model="wizard.wiki.history.show_diff" + src_model="wiki.wiki.history" + target="new" + view_mode="form" + /> + + + </data> +</openerp>
\ No newline at end of file |
