Move less used modules to extra_addons repo
bzr revid: ced-67ee0e1f0bad58fd390763b2b5a6c7d233c48223
This commit is contained in:
parent
15a2d0287a
commit
968a2cb4eb
|
@ -1,31 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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 account_asset
|
||||
import account_asset_invoice
|
||||
import wizard
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"name" : "Asset management",
|
||||
"version" : "1.0",
|
||||
"depends" : ["account", "account_simulation"],
|
||||
"author" : "Tiny",
|
||||
"description": """Financial and accounting asset management.""",
|
||||
"website" : "http://tinyerp.com/module_account.html",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"init_xml" : [
|
||||
],
|
||||
"demo_xml" : [
|
||||
],
|
||||
"update_xml" : [
|
||||
"account_asset_wizard.xml",
|
||||
"account_asset_view.xml",
|
||||
"account_asset_invoice_view.xml"
|
||||
],
|
||||
# "translations" : {
|
||||
# "fr": "i18n/french_fr.csv"
|
||||
# },
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,331 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: product.py 1310 2005-09-08 20:40:15Z pinky $
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
class account_asset_category(osv.osv):
|
||||
_name = 'account.asset.category'
|
||||
_description = 'Asset category'
|
||||
_columns = {
|
||||
'name': fields.char('Asset category', size=64, required=True, select=1),
|
||||
'code': fields.char('Asset code', size=16, select=1),
|
||||
'note': fields.text('Note'),
|
||||
}
|
||||
account_asset_category()
|
||||
|
||||
class account_asset_asset(osv.osv):
|
||||
_name = 'account.asset.asset'
|
||||
_description = 'Asset'
|
||||
|
||||
# def _balance(self, cr, uid, ids, field_name, arg, context={}):
|
||||
# acc_set = ",".join(map(str, ids))
|
||||
# query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||
# cr.execute(("SELECT a.id, COALESCE(SUM((l.debit-l.credit)),0) FROM account_asset_asset a LEFT JOIN account_move_line l ON (a.id=l.asset_account_id) WHERE a.id IN (%s) and "+query+" GROUP BY a.id") % (acc_set,))
|
||||
# res = {}
|
||||
# for account_id, sum in cr.fetchall():
|
||||
# res[account_id] = round(sum,2)
|
||||
# for id in ids:
|
||||
# res[id] = round(res.get(id,0.0), 2)
|
||||
# return res
|
||||
def _get_period(self, cr, uid, context={}):
|
||||
print context
|
||||
periods = self.pool.get('account.period').find(cr, uid)
|
||||
if periods:
|
||||
return periods[0]
|
||||
else:
|
||||
return False
|
||||
|
||||
def validate(self, cr, uid, ids, context={}):
|
||||
for asset in self.browse(cr, uid, ids, context):
|
||||
for prop in asset.property_ids:
|
||||
if prop.state=='draft':
|
||||
self.pool.get('account.asset.property').write(cr, uid, [prop.id], {'state':'open'}, context)
|
||||
return self.write(cr, uid, ids, {
|
||||
'state':'normal'
|
||||
}, context)
|
||||
|
||||
def _amount_total(self, cr, uid, ids, name, args, context={}):
|
||||
id_set=",".join(map(str,ids))
|
||||
cr.execute("""SELECT l.asset_id,abs(SUM(l.debit-l.credit)) AS amount FROM
|
||||
account_move_line l
|
||||
WHERE l.asset_id IN ("""+id_set+") GROUP BY l.asset_id ")
|
||||
res=dict(cr.fetchall())
|
||||
for id in ids:
|
||||
res.setdefault(id, 0.0)
|
||||
return res
|
||||
_columns = {
|
||||
'name': fields.char('Asset', size=64, required=True, select=1),
|
||||
'code': fields.char('Asset code', size=16, select=1),
|
||||
'note': fields.text('Note'),
|
||||
'category_id': fields.many2one('account.asset.category', 'Asset category', change_default=True),
|
||||
'localisation': fields.char('Localisation', size=32, select=2),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'parent_id': fields.many2one('account.asset.asset', 'Parent asset'),
|
||||
'child_ids': fields.one2many('account.asset.asset', 'parent_id', 'Childs asset'),
|
||||
'date': fields.date('Date', required=True),
|
||||
'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'state': fields.selection([('view','View'),('draft','Draft'),('normal','Normal'),('close','Close')], 'Global state', required=True),
|
||||
'active': fields.boolean('Active', select=2),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||
'entry_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'property_ids': fields.one2many('account.asset.property', 'asset_id', 'Asset method name', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'value_total': fields.function(_amount_total, method=True, digits=(16,2),string='Total value'),
|
||||
}
|
||||
_defaults = {
|
||||
'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),
|
||||
'date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d'),
|
||||
'active': lambda obj, cr, uid, context: True,
|
||||
'state': lambda obj, cr, uid, context: 'draft',
|
||||
'period_id': _get_period,
|
||||
}
|
||||
def _compute_period(self, cr, uid, property, context={}):
|
||||
if (len(property.entry_asset_ids or [])/2)>=property.method_delay:
|
||||
return False
|
||||
if len(property.entry_asset_ids):
|
||||
cp = property.entry_asset_ids[-1].period_id
|
||||
cpid = self.pool.get('account.period').next(cr, uid, cp, property.method_period, context)
|
||||
current_period = self.pool.get('account.period').browse(cr, uid, cpid, context)
|
||||
|
||||
else:
|
||||
current_period = property.asset_id.period_id
|
||||
return current_period
|
||||
|
||||
def _compute_move(self, cr, uid, property, period, context={}):
|
||||
result = []
|
||||
total = 0.0
|
||||
for move in property.asset_id.entry_ids:
|
||||
total += move.debit-move.credit
|
||||
for move in property.entry_asset_ids:
|
||||
if move.account_id == property.account_asset_ids:
|
||||
total += move.debit-move.credit
|
||||
periods = (len(property.entry_asset_ids)/2) - property.method_delay
|
||||
if periods==1:
|
||||
amount = total
|
||||
else:
|
||||
if property.method == 'linear':
|
||||
amount = total / periods
|
||||
else:
|
||||
amount = total * property.method_progress_factor
|
||||
|
||||
move_id = self.pool.get('account.move').create(cr, uid, {
|
||||
'journal_id': property.journal_id.id,
|
||||
'period_id': period.id,
|
||||
'name': property.name or property.asset_id.name,
|
||||
'ref': property.asset_id.code
|
||||
})
|
||||
result = [move_id]
|
||||
id = self.pool.get('account.move.line').create(cr, uid, {
|
||||
'name': property.name or property.asset_id.name,
|
||||
'move_id': move_id,
|
||||
'account_id': property.account_asset_id.id,
|
||||
'debit': amount>0 and amount or 0.0,
|
||||
'credit': amount<0 and -amount or 0.0,
|
||||
'ref': property.asset_id.code,
|
||||
'period_id': period.id,
|
||||
'journal_id': property.journal_id.id,
|
||||
'partner_id': property.asset_id.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
})
|
||||
id2 = self.pool.get('account.move.line').create(cr, uid, {
|
||||
'name': property.name or property.asset_id.name,
|
||||
'move_id': move_id,
|
||||
'account_id': property.account_actif_id.id,
|
||||
'credit': amount>0 and amount or 0.0,
|
||||
'debit': amount<0 and -amount or 0.0,
|
||||
'ref': property.asset_id.code,
|
||||
'period_id': period.id,
|
||||
'journal_id': property.journal_id.id,
|
||||
'partner_id': property.asset_id.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
})
|
||||
self.pool.get('account.asset.property').write(cr, uid, [property.id], {
|
||||
'entry_asset_ids': [(4, id2, False),(4,id,False)]
|
||||
})
|
||||
if property.method_delay - (len(property.entry_asset_ids)/2)<=1:
|
||||
self.pool.get('account.asset.property')._close(cr, uid, property, context)
|
||||
return result
|
||||
return result
|
||||
|
||||
def _compute_entries(self, cr, uid, asset, period_id, context={}):
|
||||
result = []
|
||||
date_start = self.pool.get('account.period').browse(cr, uid, period_id, context).date_start
|
||||
print 'compute entries', date_start
|
||||
for property in asset.property_ids:
|
||||
if property.state=='open':
|
||||
print 'Property State Open'
|
||||
period = self._compute_period(cr, uid, property, context)
|
||||
print period
|
||||
print period and period.date_start
|
||||
if period and (period.date_start<=date_start):
|
||||
result += self._compute_move(cr, uid, property, period, context)
|
||||
return result
|
||||
account_asset_asset()
|
||||
|
||||
class account_asset_property(osv.osv):
|
||||
def _amount_total(self, cr, uid, ids, name, args, context={}):
|
||||
id_set=",".join(map(str,ids))
|
||||
cr.execute("""SELECT l.asset_id,abs(SUM(l.debit-l.credit)) AS amount FROM
|
||||
account_asset_property p
|
||||
left join
|
||||
account_move_line l on (p.asset_id=l.asset_id)
|
||||
WHERE p.id IN ("""+id_set+") GROUP BY l.asset_id ")
|
||||
res=dict(cr.fetchall())
|
||||
for id in ids:
|
||||
res.setdefault(id, 0.0)
|
||||
return res
|
||||
|
||||
def _amount_residual(self, cr, uid, ids, name, args, context={}):
|
||||
id_set=",".join(map(str,ids))
|
||||
cr.execute("""SELECT
|
||||
r.asset_property_id,SUM(abs(l.debit-l.credit)) AS amount
|
||||
FROM
|
||||
account_move_asset_entry_rel r
|
||||
LEFT JOIN
|
||||
account_move_line l on (r.move_id=l.id)
|
||||
WHERE
|
||||
r.asset_property_id IN ("""+id_set+") GROUP BY r.asset_property_id ")
|
||||
res=dict(cr.fetchall())
|
||||
for prop in self.browse(cr, uid, ids, context):
|
||||
res[prop.id] = prop.value_total - res.get(prop.id, 0.0)
|
||||
for id in ids:
|
||||
res.setdefault(id, 0.0)
|
||||
return res
|
||||
|
||||
def _close(self, cr, uid, property, context={}):
|
||||
if property.state<>'close':
|
||||
self.pool.get('account.asset.property').write(cr, uid, [property.id], {
|
||||
'state': 'close'
|
||||
})
|
||||
property.state='close'
|
||||
ok = property.asset_id.state=='open'
|
||||
for prop in property.asset_id.property_ids:
|
||||
ok = ok and prop.state=='close'
|
||||
self.pool.get('account.asset.asset').write(cr, uid, [property.asset_id.id], {
|
||||
'state': 'close'
|
||||
}, context)
|
||||
return True
|
||||
|
||||
_name = 'account.asset.property'
|
||||
_description = 'Asset property'
|
||||
_columns = {
|
||||
'name': fields.char('Method name', size=64, select=1),
|
||||
'type': fields.selection([('direct','Direct'),('indirect','Indirect')], 'Depr. method type', select=2, required=True),
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True),
|
||||
'account_asset_id': fields.many2one('account.account', 'Asset account', required=True),
|
||||
'account_actif_id': fields.many2one('account.account', 'Depreciation account', required=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'journal_analytic_id': fields.many2one('account.analytic.journal', 'Analytic journal'),
|
||||
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
|
||||
|
||||
'method': fields.selection([('linear','Linear'),('progressif','Progressive')], 'Computation method', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_progress_factor': fields.float('Progressif factor', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_time': fields.selection([('delay','Delay'),('end','Ending period')], 'Time method', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_delay': fields.integer('Number of interval', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_period': fields.integer('Period per interval', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'method_end': fields.date('Ending date'),
|
||||
|
||||
'date': fields.date('Date created'),
|
||||
|
||||
'entry_asset_ids': fields.many2many('account.move.line', 'account_move_asset_entry_rel', 'asset_property_id', 'move_id', 'Asset Entries'),
|
||||
'board_ids': fields.one2many('account.asset.board', 'asset_id', 'Asset board'),
|
||||
|
||||
'value_total': fields.function(_amount_total, method=True, digits=(16,2),string='Gross value'),
|
||||
'value_residual': fields.function(_amount_residual, method=True, digits=(16,2), string='Residual value'),
|
||||
'state': fields.selection([('draft','Draft'), ('open','Open'), ('close','Close')], 'State', required=True),
|
||||
'history_ids': fields.one2many('account.asset.property.history', 'asset_property_id', 'History', readonly=True)
|
||||
}
|
||||
_defaults = {
|
||||
'type': lambda obj, cr, uid, context: 'direct',
|
||||
'state': lambda obj, cr, uid, context: 'draft',
|
||||
'method': lambda obj, cr, uid, context: 'linear',
|
||||
'method_time': lambda obj, cr, uid, context: 'delay',
|
||||
'method_progress_factor': lambda obj, cr, uid, context: 0.3,
|
||||
'method_delay': lambda obj, cr, uid, context: 5,
|
||||
'method_period': lambda obj, cr, uid, context: 12,
|
||||
'date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d')
|
||||
}
|
||||
account_asset_property()
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
_inherit = 'account.move.line'
|
||||
_columns = {
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset'),
|
||||
}
|
||||
account_move_line()
|
||||
|
||||
class account_asset_property_history(osv.osv):
|
||||
_name = 'account.asset.property.history'
|
||||
_description = 'Asset history'
|
||||
_columns = {
|
||||
'name': fields.char('History name', size=64, select=1),
|
||||
'user_id': fields.many2one('res.users', 'User', required=True),
|
||||
'date': fields.date('Date', required=True),
|
||||
'asset_property_id': fields.many2one('account.asset.property', 'Method', required=True),
|
||||
'method_delay': fields.integer('Number of interval'),
|
||||
'method_period': fields.integer('Period per interval'),
|
||||
'method_end': fields.date('Ending date'),
|
||||
'note': fields.text('Note'),
|
||||
}
|
||||
_defaults = {
|
||||
'date': lambda *args: time.strftime('%Y-%m-%d'),
|
||||
'user_id': lambda self,cr, uid,ctx: uid
|
||||
}
|
||||
account_asset_property_history()
|
||||
|
||||
|
||||
class account_asset_board(osv.osv):
|
||||
_name = 'account.asset.board'
|
||||
_description = 'Asset board'
|
||||
_columns = {
|
||||
'name': fields.char('Asset name', size=64, required=True, select=1),
|
||||
'asset_id': fields.many2one('account.asset.property', 'Asset', required=True, select=1),
|
||||
'value_gross': fields.float('Gross value', required=True, select=1),
|
||||
'value_asset': fields.float('Asset Value', required=True, select=1),
|
||||
'value_asset_cumul': fields.float('Cumul. value', required=True, select=1),
|
||||
'value_net': fields.float('Net value', required=True, select=1),
|
||||
}
|
||||
_auto = False
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view account_asset_board as (
|
||||
select
|
||||
min(l.id) as id,
|
||||
min(l.id) as asset_id,
|
||||
0.0 as value_gross,
|
||||
0.0 as value_asset,
|
||||
0.0 as value_asset_cumul,
|
||||
0.0 as value_net
|
||||
from
|
||||
account_move_line l
|
||||
where
|
||||
l.state <> 'draft' and
|
||||
l.asset_id=3
|
||||
)""")
|
||||
account_asset_board()
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: product.py 1310 2005-09-08 20:40:15Z pinky $
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
|
||||
class account_invoice(osv.osv):
|
||||
_inherit = 'account.invoice'
|
||||
def line_get_convert(self, cr, uid, x, part, date, context={}):
|
||||
print self
|
||||
res = super(account_invoice, self).line_get_convert(cr, uid, x, part, date, context)
|
||||
res['asset_id'] = x.get('asset_id', False)
|
||||
return res
|
||||
account_invoice()
|
||||
|
||||
class account_invoice_line(osv.osv):
|
||||
_inherit = 'account.invoice.line'
|
||||
_columns = {
|
||||
'asset_id': fields.many2one('account.asset.asset', 'Asset'),
|
||||
}
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
res = super(account_invoice_line, self).move_line_get_item(cr, uid, line, context)
|
||||
res['asset_id'] = line.asset_id.id or False
|
||||
if line.asset_id.id and (line.asset_id.state=='draft'):
|
||||
self.pool.get('account.asset.asset').validate(cr, uid, [line.asset_id.id], context)
|
||||
return res
|
||||
account_invoice_line()
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
#---------------------------------------------------------
|
||||
# Fiscal Year
|
||||
#---------------------------------------------------------
|
||||
|
||||
<record model="ir.ui.view" id="view_account_invoice_asset_form">
|
||||
<field name="name">account.invoice.line.form</field>
|
||||
<field name="model">account.invoice.line</field>
|
||||
<field name="inherit_id" ref="account.view_invoice_line_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="price_subtotal" position="after">
|
||||
<field name="asset_id" context="name=name"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,278 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_category_form">
|
||||
<field name="name">account.asset.category.form</field>
|
||||
<field name="model">account.asset.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset category">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="note" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_category_tree">
|
||||
<field name="name">account.asset.category.tree</field>
|
||||
<field name="model">account.asset.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Asset category">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_account_asset_category_form">
|
||||
<field name="name">Asset Category</field>
|
||||
<field name="res_model">account.asset.category</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Assets/"
|
||||
id="menu_action_account_asset_category_form"
|
||||
action="action_account_asset_category_form"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_property_tree">
|
||||
<field name="name">account.asset.property.tree</field>
|
||||
<field name="model">account.asset.property</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets methods">
|
||||
<field name="asset_id"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="value_total"/>
|
||||
<field name="value_residual"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_asset_form">
|
||||
<field name="name">account.asset.asset.form</field>
|
||||
<field name="model">account.asset.asset</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset">
|
||||
<notebook>
|
||||
<page string="General info">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
<field name="period_id" select="2"/>
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="property_ids" colspan="4" nolabel="1" mode="form,tree">
|
||||
<form string="Depreciation methods">
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<notebook string="Methods" tabpos="up" colspan="4">
|
||||
<page string="Depreciation">
|
||||
<separator string="Accounts information" colspan="4"/>
|
||||
<field name="account_asset_id"/>
|
||||
<field name="account_actif_id"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="type"/>
|
||||
<field name="account_analytic_id"/>
|
||||
<field name="journal_analytic_id"/>
|
||||
<separator string="Depreciation duration" colspan="4"/>
|
||||
<field name="method"/>
|
||||
<field name="method_progress_factor"/>
|
||||
<field name="method_time"/>
|
||||
<field name="method_delay"/>
|
||||
<field name="method_period"/>
|
||||
<button
|
||||
name="%(wizard_asset_modify)d"
|
||||
states="open"
|
||||
string="Change duration"
|
||||
type="action"
|
||||
colspan="2"/>
|
||||
<!-- <field name="method_end"/> -->
|
||||
</page>
|
||||
<page string="Depreciation entries">
|
||||
<field name="entry_asset_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
</page>
|
||||
<page string="Change history">
|
||||
<field name="history_ids" colspan="4" nolabel="1" readonly="1"/>
|
||||
</page>
|
||||
<page string="Depreciation board">
|
||||
<field name="value_total"/>
|
||||
<field name="value_residual"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="state" readonly="1"/>
|
||||
<button name="%(wizard_asset_close)d" states="open" string="Close method" type="action"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="state" readonly="1"/>
|
||||
<group colspan="2" col="2">
|
||||
<button name="validate" states="draft" string="Confirm asset" type="object"/>
|
||||
</group>
|
||||
</page><page string="Entries">
|
||||
<field name="entry_ids" colspan="4" nolabel="1"/>
|
||||
</page><page string="Other information">
|
||||
<field name="date" select="2"/>
|
||||
<field name="sequence"/>
|
||||
<field name="partner_id" select="2"/>
|
||||
<field name="localisation" select="2"/>
|
||||
<field name="parent_id" select="2"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_property_history_form">
|
||||
<field name="name">account.asset.property.history.form</field>
|
||||
<field name="model">account.asset.property.history</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset history">
|
||||
<field name="name" select="1"/>
|
||||
<field name="date" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="method_delay" select="2"/>
|
||||
<field name="method_period"/>
|
||||
<field name="method_end"/>
|
||||
<separator string="Notes" colspan="4"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_property_history_tree">
|
||||
<field name="name">account.asset.property.history.tree</field>
|
||||
<field name="model">account.asset.property.history</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Asset history">
|
||||
<field name="date" select="1"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="method_delay" select="2"/>
|
||||
<field name="method_period"/>
|
||||
<field name="method_end"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_board_form">
|
||||
<field name="name">account.asset.board.form</field>
|
||||
<field name="model">account.asset.board</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Asset board">
|
||||
<field name="name" select="1"/>
|
||||
<field name="asset_id" select="1"/>
|
||||
<field name="value_gross" select="2"/>
|
||||
<field name="value_asset"/>
|
||||
<field name="value_asset_cumul"/>
|
||||
<field name="value_net"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_account_asset_board_tree">
|
||||
<field name="name">account.asset.board.tree</field>
|
||||
<field name="model">account.asset.board</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Asset board">
|
||||
<field name="name"/>
|
||||
<field name="asset_id"/>
|
||||
<field name="value_gross"/>
|
||||
<field name="value_asset"/>
|
||||
<field name="value_asset_cumul"/>
|
||||
<field name="value_net"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_asset_asset_tree">
|
||||
<field name="name">account.asset.asset.tree</field>
|
||||
<field name="model">account.asset.asset</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assets">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="value_total"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_form">
|
||||
<field name="name">Asset</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Assets/"
|
||||
id="menu_action_account_asset_asset_form"
|
||||
action="action_account_asset_asset_form"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_tree">
|
||||
<field name="name">Asset Hierarchy</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">tree</field>
|
||||
<field name="domain">[('parent_id','=',False)]</field>
|
||||
<field name="view_id" ref="view_account_asset_asset_tree"/>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/"
|
||||
id="menu_action_account_asset_asset_tree"
|
||||
action="action_account_asset_asset_tree"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_list">
|
||||
<field name="name">Assets</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/Assets"
|
||||
id="menu_action_account_asset_asset_list"
|
||||
action="action_account_asset_asset_list"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_list_draft">
|
||||
<field name="name">Draft Assets</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','draft')]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/Assets/"
|
||||
id="menu_action_account_asset_asset_list_draft"
|
||||
action="action_account_asset_asset_list_draft"/>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_asset_asset_list_normal">
|
||||
<field name="name">Open Assets</field>
|
||||
<field name="res_model">account.asset.asset</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','normal')]</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Assets/Assets/"
|
||||
id="menu_action_account_asset_asset_list_normal"
|
||||
action="action_account_asset_asset_list_normal"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<wizard
|
||||
string="Compute assets"
|
||||
model="account.asset.asset"
|
||||
name="account.asset.compute"
|
||||
keyword="tree_but_action"
|
||||
id="wizard_asset_compute"/>
|
||||
<menuitem
|
||||
name="Financial Management/Periodical Processing/Compute Assets"
|
||||
action="wizard_asset_compute"
|
||||
type="wizard"
|
||||
id="menu_wizard_asset_compute"/>
|
||||
|
||||
|
||||
<wizard
|
||||
string="Modify asset"
|
||||
model="account.asset.asset"
|
||||
name="account.asset.modify"
|
||||
id="wizard_asset_modify"
|
||||
menu="False"/>
|
||||
<wizard
|
||||
string="Close asset"
|
||||
model="account.asset.asset"
|
||||
name="account.asset.close"
|
||||
id="wizard_asset_close"
|
||||
menu="False"/>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,31 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# 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_asset_compute
|
||||
import wizard_asset_close
|
||||
import wizard_asset_modify
|
|
@ -1,56 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# 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 pooler
|
||||
|
||||
asset_end_arch = '''<?xml version="1.0"?>
|
||||
<form string="Close asset">
|
||||
<separator string="General information" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
asset_end_fields = {
|
||||
}
|
||||
|
||||
class wizard_asset_close(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':asset_end_arch, 'fields':asset_end_fields, 'state':[
|
||||
('end','Cancel'),
|
||||
('asset_close','End of asset')
|
||||
]}
|
||||
},
|
||||
'asset_close': {
|
||||
'actions': [],
|
||||
'result': {'type' : 'state', 'state': 'end'}
|
||||
}
|
||||
}
|
||||
wizard_asset_close('account.asset.close')
|
||||
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# 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 pooler
|
||||
|
||||
asset_end_arch = '''<?xml version="1.0"?>
|
||||
<form string="Compute assets">
|
||||
<separator string="Generated entries" colspan="4"/>
|
||||
<field name="move_ids" readonly="1" nolabel="1"/>
|
||||
</form>'''
|
||||
|
||||
asset_end_fields = {
|
||||
'move_ids': {'string':'Entries', 'type': 'one2many', 'relation':'account.move'},
|
||||
}
|
||||
|
||||
|
||||
asset_ask_form = '''<?xml version="1.0"?>
|
||||
<form string="Compute assets">
|
||||
<field name="period_id"/>
|
||||
</form>'''
|
||||
|
||||
asset_ask_fields = {
|
||||
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
||||
}
|
||||
|
||||
def _asset_compute(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ass_obj = pool.get('account.asset.asset')
|
||||
ids = ass_obj.search(cr, uid, [('state','=','normal')], context)
|
||||
ids_create = []
|
||||
for asset in ass_obj.browse(cr, uid, ids, context):
|
||||
ids_create += ass_obj._compute_entries(cr, uid, asset, data['form']['period_id'], context)
|
||||
self.move_ids = ids_create
|
||||
return {'move_ids': ids_create}
|
||||
|
||||
def _asset_open(self, cr, uid, data, context):
|
||||
value = {
|
||||
'name': 'Created moves',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move',
|
||||
'view_id': False,
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
if data['form']['move_ids']:
|
||||
value['domain']= "[('id','in',["+','.join(map(str,self.move_ids))+"])]"
|
||||
else:
|
||||
value['domain']= "[('id','=', False)]"
|
||||
print value
|
||||
return value
|
||||
|
||||
def _get_period(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = pool.get('account.period').find(cr, uid, context=context)
|
||||
period_id = False
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
return {'period_id': period_id}
|
||||
|
||||
class wizard_asset_compute(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_period],
|
||||
'result': {'type':'form', 'arch':asset_ask_form, 'fields':asset_ask_fields, 'state':[
|
||||
('end','Cancel'),
|
||||
('asset_compute','Compute assets')
|
||||
]}
|
||||
},
|
||||
'asset_compute': {
|
||||
'actions': [_asset_compute],
|
||||
'result': {'type' : 'form', 'arch': asset_end_arch, 'fields':asset_end_fields, 'state':[
|
||||
('end','Close'),
|
||||
('asset_open','Open entries')
|
||||
]}
|
||||
},
|
||||
'asset_open': {
|
||||
'actions': [],
|
||||
'result': {'type':'action', 'action': _asset_open, 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_asset_compute('account.asset.compute')
|
||||
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# 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 pooler
|
||||
|
||||
asset_end_arch = '''<?xml version="1.0"?>
|
||||
<form string="Modify asset">
|
||||
<separator string="Asset properties to modify" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="method_delay"/>
|
||||
<field name="method_period"/>
|
||||
<separator string="Notes" colspan="4"/>
|
||||
<field name="note" nolabel="1" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
asset_end_fields = {
|
||||
'name': {'string':'Reason', 'type':'char', 'size':64, 'required':True},
|
||||
'method_delay': {'string':'Number of interval', 'type':'float'},
|
||||
'method_period': {'string':'Period per interval', 'type':'float'},
|
||||
'note': {'string':'Notes', 'type':'text'},
|
||||
}
|
||||
|
||||
def _asset_default(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
prop = pool.get('account.asset.property').browse(cr, uid, data['id'], context)
|
||||
return {
|
||||
'name': prop.name,
|
||||
'method_delay': prop.method_delay,
|
||||
'method_period': prop.method_period
|
||||
}
|
||||
|
||||
def _asset_modif(self, cr, uid, data, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
prop = pool.get('account.asset.property').browse(cr, uid, data['id'], context)
|
||||
print prop
|
||||
pool.get('account.asset.property.history').create(cr, uid, {
|
||||
'asset_property_id': data['id'],
|
||||
'name': prop.name,
|
||||
'method_delay': prop.method_delay,
|
||||
'method_period': prop.method_period,
|
||||
'note': data['form']['note'],
|
||||
}, context)
|
||||
pool.get('account.asset.property').write(cr, uid, [data['id']], {
|
||||
'name': data['form']['name'],
|
||||
'method_delay': data['form']['method_delay'],
|
||||
'method_period': data['form']['method_period'],
|
||||
}, context)
|
||||
return {}
|
||||
|
||||
|
||||
class wizard_asset_modify(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_asset_default],
|
||||
'result': {'type':'form', 'arch':asset_end_arch, 'fields':asset_end_fields, 'state':[
|
||||
('end','Cancel'),
|
||||
('asset_modify','Modify asset')
|
||||
]}
|
||||
},
|
||||
'asset_modify': {
|
||||
'actions': [_asset_modif],
|
||||
'result': {'type' : 'state', 'state': 'end'}
|
||||
}
|
||||
}
|
||||
wizard_asset_modify('account.asset.modify')
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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 account_cash_discount
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"name" : "Payement Term with Cash Discount",
|
||||
"version" : "1.0",
|
||||
"depends" : ["account",],
|
||||
"author" : "Tiny",
|
||||
"description" : "",
|
||||
"website" : "http://tinyerp.com/",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"description": """
|
||||
This module adds cash discounts on payment terms. Cash discounts
|
||||
for a payment term can be configured with:
|
||||
* A number of days,
|
||||
* A discount (%),
|
||||
* A debit and a credit account
|
||||
""",
|
||||
"init_xml" : [
|
||||
],
|
||||
"demo_xml" : [
|
||||
],
|
||||
"update_xml" : [
|
||||
"account_cash_discount_view.xml",
|
||||
],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime
|
||||
|
||||
class account_payment_term(osv.osv):
|
||||
_name = "account.payment.term"
|
||||
_inherit = "account.payment.term"
|
||||
_columns = {
|
||||
'cash_discount_ids': fields.one2many('account.cash.discount', 'payment_id', 'Cash Discounts'),
|
||||
}
|
||||
def get_discounts(self,cr,uid,id,base_date, context={}):
|
||||
"""
|
||||
return the list of (date,percentage) ordered by date for the
|
||||
payment term with the corresponding id. return [] if no cash
|
||||
discount are defined. base_date is the date from where the
|
||||
discounts are computed.
|
||||
"""
|
||||
|
||||
pt = self.browse(cr, uid, id, context)
|
||||
|
||||
if not pt.cash_discount_ids:
|
||||
return []
|
||||
|
||||
res=[]
|
||||
for d in pt.cash_discount_ids:
|
||||
res.append(
|
||||
((mx.DateTime.strptime(base_date,'%Y-%m-%d') +\
|
||||
RelativeDateTime(days=d.delay+1)).strftime("%Y-%m-%d"),
|
||||
d.discount)
|
||||
)
|
||||
|
||||
res.sort(cmp=lambda x,y: cmp(x[0],y[0]))
|
||||
return res
|
||||
account_payment_term()
|
||||
|
||||
class account_cash_discount(osv.osv):
|
||||
_name = "account.cash.discount"
|
||||
_description = "Cash Discount" #A reduction in the price if payment is made within a stipulated period.
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=32),
|
||||
'delay': fields.integer('Number of Days', required=True),
|
||||
'discount': fields.float('Discount (%)', digits=(16,6),required=True),
|
||||
'payment_id': fields.many2one('account.payment.term','Associated Payment Term'),
|
||||
'credit_account_id': fields.many2one('account.account', 'Credit Account'),
|
||||
'debit_account_id': fields.many2one('account.account', 'Debit Account'),
|
||||
}
|
||||
account_cash_discount()
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<!-- cash discount -->
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_cash_discount_form">
|
||||
<field name="name">account.cash.discount.form</field>
|
||||
<field name="model">account.cash.discount</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Cash Discount">
|
||||
<field name="name" select="1"/>
|
||||
<field name="delay" select="1"/>
|
||||
<field name="discount" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_cash_discount_tree">
|
||||
<field name="name">account.cash.discount.tree</field>
|
||||
<field name="model">account.cash.discount</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Cash Discount" editable="bottom">
|
||||
<field name="name" select="1"/>
|
||||
<field name="delay" select="1"/>
|
||||
<field name="discount" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_payment_term_form">
|
||||
<field name="name">account.payment.term.form</field>
|
||||
<field name="model">account.payment.term</field>
|
||||
<field name="inherit_id" ref="account.view_payment_term_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="line_ids" position="after">
|
||||
<field name="cash_discount_ids" colspan="4"/>
|
||||
<separator string="Cash Discount" colspan="4"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,30 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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 account_simulation
|
||||
import wizard
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name" : "Accounting simulation journal",
|
||||
"version" : "1.0",
|
||||
"depends" : ["account"],
|
||||
"author" : "Tiny",
|
||||
"description": """Accounting simulation plan.""",
|
||||
"website" : "http://tinyerp.com/module_account.html",
|
||||
"category" : "Generic Modules/Accounting",
|
||||
"init_xml" : [
|
||||
],
|
||||
"demo_xml" : [
|
||||
"account_simulation_demo.xml"
|
||||
],
|
||||
"update_xml" : [ "account_simulation_view.xml" ],
|
||||
# "translations" : {
|
||||
# "fr": "i18n/french_fr.csv"
|
||||
# },
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
class account_journal_simulation(osv.osv):
|
||||
_name = "account.journal.simulation"
|
||||
_description = "Simulation level"
|
||||
_columns = {
|
||||
'name': fields.char('Simulation name', size=32, required=True),
|
||||
'code': fields.char('Simulation code', size=8, required=True),
|
||||
}
|
||||
_sql_constraints = [
|
||||
('code_uniq', 'unique (code)', 'The code of the simulation must be unique !')
|
||||
]
|
||||
_order = "name"
|
||||
account_journal_simulation()
|
||||
|
||||
def _state_simul_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('account.journal.simulation')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['code', 'name'], context)
|
||||
return [('valid','Base')]+ [(r['code'], r['name']) for r in res]
|
||||
|
||||
class account_journal(osv.osv):
|
||||
_inherit = "account.journal"
|
||||
_columns = {
|
||||
'state': fields.selection(_state_simul_get, 'Status', required=True),
|
||||
'parent_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_src_id', 'journal_dest_id', 'Childs journal'),
|
||||
'child_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_dest_id', 'journal_src_id', 'Parent journal'),
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda self,cr,uid,context: 'valid'
|
||||
}
|
||||
account_journal()
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
_inherit = "account.move.line"
|
||||
def search_not_run(self, cr, uid, crit, offset=0, limit=None, order=None, context={}):
|
||||
if not 'fiscalyear' in context:
|
||||
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
ok = True
|
||||
for c in crit:
|
||||
if c[0]=='journal_id':
|
||||
ok = False
|
||||
break
|
||||
if 'journal_id' in context:
|
||||
ok=False
|
||||
if ok:
|
||||
plus = ''
|
||||
for state in context.get('journal_state', []):
|
||||
plus+=",'"+state+"'"
|
||||
cr.execute("select id from account_journal where state in ('valid'"+plus+")")
|
||||
crit.append(('journal_id', 'in', map(lambda x: x[0], cr.fetchall())))
|
||||
res = super(account_move_line, self).search(cr, uid, crit, offset, limit, order, context)
|
||||
return res
|
||||
|
||||
def _query_get(self, cr, uid, obj='l', context={}):
|
||||
res = super(account_move_line, self)._query_get(cr, uid, obj, context)
|
||||
if context.get('journal_state', []):
|
||||
plus = " and (l.journal_id in (select id from account_journal where state in ('valid', "+','.join(map(lambda x: "'"+x+"'", context['journal_state']))+")))"
|
||||
else:
|
||||
plus = " and (l.journal_id in (select id from account_journal where state='valid'))"
|
||||
return res+plus
|
||||
account_move_line()
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
|
||||
<!--
|
||||
Journal Simulation
|
||||
-->
|
||||
|
||||
<record model="account.journal.simulation" id="journal_sim0">
|
||||
<field name="name">Simulation Level 0</field>
|
||||
<field name="code">sim0</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_simulation_tree">
|
||||
<field name="name">account.journal.simulation.tree</field>
|
||||
<field name="model">account.journal.simulation</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Journal simulation">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_simulation_form">
|
||||
<field name="name">account.journal.simulation.form</field>
|
||||
<field name="model">account.journal.simulation</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Journal simulation">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_view_account_journal_simulation_form">
|
||||
<field name="name">Journal Simulations</field>
|
||||
<field name="res_model">account.journal.simulation</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Journal/"
|
||||
id="menu_action_view_account_journal_simulation_form"
|
||||
action="action_view_account_journal_simulation_form"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_form_inherit_simul">
|
||||
<field name="name">account.journal.simulation.form.inherit</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="update_posted" position="after">
|
||||
<field name="state"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_account_journal_tree">
|
||||
<field name="name">account.journal.tree</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Account Journal">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_account_journal_tree">
|
||||
<field name="name">Account Journal</field>
|
||||
<field name="res_model">account.journal</field>
|
||||
<field name="view_type">tree</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/Journal/Journal Architecture"
|
||||
id="menu_action_account_journal_tree"
|
||||
action="action_account_journal_tree"/>
|
||||
|
||||
<wizard string="Accounts Charts" menu="False" model="account.account" name="account.simulation.chart" id="account.wizard_account_chart"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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_account_chart
|
|
@ -1,81 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2007 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 pooler
|
||||
|
||||
class wizard_account_chart(wizard.interface):
|
||||
_account_chart_arch = '''<?xml version="1.0"?>
|
||||
<form string="Account charts">
|
||||
<field name="fiscalyear"/>
|
||||
<separator string="Simulations" colspan="4"/>
|
||||
<field name="states" colspan="4" nolabel="1"/>
|
||||
</form>'''
|
||||
|
||||
_account_chart_fields = {
|
||||
'fiscalyear': {'string': 'Fiscal year', 'type':'many2one','relation': 'account.fiscalyear', 'required': True },
|
||||
'states': {'string':'States', 'type':'many2many', 'relation':'account.journal.simulation'},
|
||||
}
|
||||
|
||||
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):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
mod_obj = pool.get('ir.model.data')
|
||||
act_obj = 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])[0]
|
||||
|
||||
ctx = {'fiscalyear': data['form']['fiscalyear']}
|
||||
|
||||
|
||||
if data['form']['states']:
|
||||
ctx['journal_state']=[]
|
||||
sim_obj = pooler.get_pool(cr.dbname).get('account.journal.simulation')
|
||||
for a in sim_obj.read(cr, uid, data['form']['states'][0][2], ['code'], context):
|
||||
ctx['journal_state'].append(a['code'])
|
||||
result['context'] = str(ctx)
|
||||
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.simulation.chart')
|
Binary file not shown.
Before Width: | Height: | Size: 10 KiB |
|
@ -1,29 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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 custom
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"name" : "Airport",
|
||||
"author" : "Tiny",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base", "product"],
|
||||
"description": "Sample module to manage airport, flights and hostels",
|
||||
"init_xml" : [],
|
||||
"update_xml" : ["custom_view.xml", "custom_report.xml"],
|
||||
"category" : "Enterprise Specific Modules/Travel Agencies",
|
||||
"active": False,
|
||||
"installable": False
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
from osv import osv, fields
|
||||
|
||||
class airport_airport(osv.osv):
|
||||
_name = 'airport.airport'
|
||||
_columns = {
|
||||
'name': fields.char('Airport name', size=16),
|
||||
'city': fields.char('City', size=16),
|
||||
'country_id': fields.many2one('res.country', 'Country'),
|
||||
'lines': fields.many2many('airport.airport', 'airport_airport_lines_rel', 'source','destination', 'Flight lines')
|
||||
}
|
||||
airport_airport()
|
||||
|
||||
class airport_flight(osv.osv):
|
||||
_name = 'airport.flight'
|
||||
_inherit = 'product.product'
|
||||
_table = 'product_product'
|
||||
_columns = {
|
||||
'date': fields.datetime('Departure Date'),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer'),
|
||||
'airport_from': fields.many2one('airport.airport', 'Airport Departure'),
|
||||
'airport_to': fields.many2one('airport.airport', 'Airport Arrival'),
|
||||
}
|
||||
airport_flight()
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<report
|
||||
string="Custom Ticket"
|
||||
model="airport.flight"
|
||||
name="airport flight"
|
||||
rml="airport/ticket.rml"
|
||||
/>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,66 +0,0 @@
|
|||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_airport_form">
|
||||
<field name="res_model">airport.airport</field>
|
||||
</record>
|
||||
<menuitem name="Airports/Configuration/Airport" id="menu_action_airport_form" action="action_airport_form"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="v3">
|
||||
<field name="name">airport.airport</field>
|
||||
<field name="model">airport.airport</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">lines</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Flight">
|
||||
<field name="name"/>
|
||||
<field name="city"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_custom_airport_tree">
|
||||
<field name="res_model">airport.airport</field>
|
||||
<field name="view_type">tree</field>
|
||||
</record>
|
||||
<menuitem name="Airports/Air Lines" id="menu_action_custom_airport_tree" action="action_custom_airport_tree"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="v4">
|
||||
<field name="name">airport.airport</field>
|
||||
<field name="model">airport.airport</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Flight">
|
||||
<field name="name" colspan="4" select="1"/>
|
||||
<field name="city" select="1" />
|
||||
<field name="country_id" select="1" />
|
||||
<field name="lines" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_custom_flight_form">
|
||||
<field name="res_model">airport.flight</field>
|
||||
</record>
|
||||
<menuitem name="Airports/Configuration/Flights" id="menu_action_custom_flight_form" action="action_custom_flight_form"/>
|
||||
<record model="ir.ui.view" id="v2">
|
||||
<field name="name">airport.flight</field>
|
||||
<field name="model">airport.flight</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Flight">
|
||||
<field name="name" select="1"/>
|
||||
<field name="date" select="1" />
|
||||
<field name="categ_id" select="1" />
|
||||
<field name="partner_id" select="1" />
|
||||
<field name="airport_from" select="1" />
|
||||
<field name="airport_to" select="1" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<document filename="test.pdf">
|
||||
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
|
||||
</pageTemplate>
|
||||
</template>
|
||||
<stylesheet>
|
||||
<blockTableStyle id="Standard_Outline">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table1">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="GRID" colorName="black"/>
|
||||
<blockBackground colorName="#9999cc" start="1,0" stop="1,0"/>
|
||||
<blockBackground colorName="#ccccff" start="0,1" stop="0,1"/>
|
||||
<blockBackground colorName="#ccccff" start="1,1" stop="1,1"/>
|
||||
</blockTableStyle>
|
||||
<initialize>
|
||||
<paraStyle name="all" alignment="justify"/>
|
||||
</initialize>
|
||||
<paraStyle name="P1" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P2" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P3" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P4" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P5" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P6" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="P8" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Standard" fontName="Times-Roman"/>
|
||||
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Index" fontName="Times-Roman"/>
|
||||
</stylesheet>
|
||||
<story>
|
||||
<para style="Standard">[[ repeatIn(objects,'o') ]]</para>
|
||||
<para style="Standard">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="Standard">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<blockTable colWidths="241.0,241.0" repeatRows="1" style="Table1">
|
||||
<tr>
|
||||
<td>
|
||||
<illustration height="75.0" width="235.0">
|
||||
<image x="0" y="0" file="1000000000000144000000689888B27C.gif" height="75.0" width="235.0"/>
|
||||
</illustration>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P1">TO: [[ o.partner_id.name ]]</para>
|
||||
<para style="P2">[[ o.partner_id.address[0].name ]]</para>
|
||||
<para style="P3">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="P4">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="P5">This ticket can be be reimbursed.See sales</para>
|
||||
<para style="P5">conditions in your travel agency contract.</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P6">Departure:</para>
|
||||
<para style="P7">[[ o.airport_from.name ]]</para>
|
||||
<para style="P7">[[ o.airport_from.country_id.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P8">Arrival:</para>
|
||||
<para style="P7">[[ o.airport_to.name ]]</para>
|
||||
<para style="P7">[[ o.airport_to.country_id.name ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="Standard">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</story>
|
||||
</document>
|
||||
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
import analytic_partners
|
||||
import report
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"name" : "Analytic accounts with multiple partners",
|
||||
"author" : "Tiny",
|
||||
"version" : "1.0",
|
||||
"category" : "Generic Modules/Others",
|
||||
"depends" : ["account"],
|
||||
"description": """
|
||||
This module adds the possibility to assign multiple partners on
|
||||
the same analytic account. It's usefull when you do a management
|
||||
by affairs, where you can attach all suppliers and customers to
|
||||
a project.
|
||||
|
||||
A report for the project manager is added to print the analytic
|
||||
account and all associated partners with their contacts.
|
||||
|
||||
It's usefull to give to all members of a project, so that they
|
||||
get the contacts of all suppliers in this project.
|
||||
""",
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ["analytic_partners_view.xml",
|
||||
"analytic_partners_report.xml"],
|
||||
"init_xml" : [],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
from osv import osv, fields
|
||||
|
||||
class analytic_partners_account_analytic_account(osv.osv) :
|
||||
_name = 'account.analytic.account'
|
||||
_inherit = 'account.analytic.account'
|
||||
_columns = {
|
||||
'address_ids' : fields.many2many('res.partner.address', 'account_partner_rel', 'account_id', 'address_id', 'Partners Contacts'),
|
||||
}
|
||||
|
||||
analytic_partners_account_analytic_account()
|
|
@ -1,11 +0,0 @@
|
|||
<terp>
|
||||
<data>
|
||||
<report id="analytic_partners_report"
|
||||
string="Analytic Account with Partners"
|
||||
model="account.analytic.account"
|
||||
name="analytic_partners.print"
|
||||
rml="analytic_partners/report/analytic_account_partners.rml"
|
||||
auto="False"
|
||||
/>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,18 +0,0 @@
|
|||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="analytic_partners_analytic_account_form">
|
||||
<field name="name">analytic_partners.analytic.account.form</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_account_analytic_account_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<notebook>
|
||||
<page string="Partners">
|
||||
<field colspan="4" name="address_ids"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1 +0,0 @@
|
|||
import analytic_partners_report
|
|
@ -1,140 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<document filename="test.pdf">
|
||||
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<frame id="first" x1="35.0" y1="48.0" width="525" height="746"/>
|
||||
</pageTemplate>
|
||||
</template>
|
||||
<stylesheet>
|
||||
<blockTableStyle id="Standard_Outline">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table3">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
|
||||
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
|
||||
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
|
||||
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
|
||||
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
|
||||
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table1">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="GRID" colorName="black"/>
|
||||
<blockBackground colorName="#ffffcc" start="0,0" stop="0,0"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table2">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="GRID" colorName="black"/>
|
||||
</blockTableStyle>
|
||||
<initialize>
|
||||
<paraStyle name="all" alignment="justify"/>
|
||||
</initialize>
|
||||
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8"/>
|
||||
<paraStyle name="P2" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER"/>
|
||||
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
|
||||
<paraStyle name="P4" fontName="Times-Roman" alignment="CENTER"/>
|
||||
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT"/>
|
||||
<paraStyle name="P6" fontName="Times-Roman"/>
|
||||
<paraStyle name="P7" fontName="Times-Roman" fontSize="6.0" leading="8"/>
|
||||
<paraStyle name="P8" fontName="Times-Roman" alignment="CENTER"/>
|
||||
<paraStyle name="P9" fontName="Times-Roman"/>
|
||||
<paraStyle name="P10" fontName="Times-Roman" fontSize="11.0" leading="14"/>
|
||||
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14"/>
|
||||
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14"/>
|
||||
<paraStyle name="Standard" fontName="Times-Roman"/>
|
||||
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Table Contents" fontName="Times-Roman"/>
|
||||
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
|
||||
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Index" fontName="Times-Roman"/>
|
||||
</stylesheet>
|
||||
<story>
|
||||
<para style="P1">[[repeatIn(objects, 'o')]]</para>
|
||||
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table3">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="Table Contents">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P2">Partner listing</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P3">Printed: [[ time.strftime('%d-%m-%Y') ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="Table Contents">[[ company.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P4">[[ o['name'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P5">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="P6">[[ _init_dict(o) ]]</para>
|
||||
<section>
|
||||
<para style="P7">[[ repeatIn(partners_by_account.keys(), 'cat') ]]</para>
|
||||
<blockTable colWidths="525.0" style="Table1">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P8">[[ cat ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="P6">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<section>
|
||||
<para style="P9"><font face="Times-Roman">[[ repeatIn(partners_by_account[cat], 'p') ]] </font>[[ p.name ]] - [[ p.vat ]]</para>
|
||||
<blockTable colWidths="186.0,169.0,169.0" style="Table2">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="Table Contents">Contact</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="Table Contents">Address</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="Table Contents">Information</para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P10"><font face="Times-Roman">[[ repeatIn(p.address, 'a') ]] </font>[[ a.name ]]</para>
|
||||
<para style="P11">[[ a.function ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P10">[[ a.street ]] [[ a.street2 ]]</para>
|
||||
<para style="P10">[[ a.zip ]] [[ a.city ]]</para>
|
||||
<para style="P10">[[ a.country_id and a.country_id.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P10"><font face="Times-Roman">Tel</font> : [[ a.phone ]]</para>
|
||||
<para style="P10"><font face="Times-Roman">Fax</font> : [[ a.fax ]]</para>
|
||||
<para style="P10"><font face="Times-Roman">Mobile</font> : [[ a.mobile ]]</para>
|
||||
<para style="P12">Mail<font face="Times-Roman"> : [[ a.email ]]</font></para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="P6">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</story>
|
||||
</document>
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import pooler
|
||||
import time
|
||||
from report import report_sxw
|
||||
|
||||
class analytic_partners_report(report_sxw.rml_parse):
|
||||
# o must be an instance of
|
||||
# analytic_partners_account_analytic_account.
|
||||
def _init_dict(self, o):
|
||||
self.partners_by_account.clear()
|
||||
for a in o.address_ids:
|
||||
p = a.partner_id
|
||||
for c in p.category_id:
|
||||
self.partners_by_account.setdefault(c.name, []).append(a)
|
||||
if not p.category_id:
|
||||
self.partners_by_account.setdefault('Non classifie', []).append(a)
|
||||
|
||||
|
||||
def __init__(self, cr, uid, name, context):
|
||||
# self.partners_by_account is a dictionnary where keys are category
|
||||
# names and values are lists of partner_id.
|
||||
self.partners_by_account={}
|
||||
super(analytic_partners_report, self).__init__(cr, uid, name, context)
|
||||
self.localcontext.update( {
|
||||
'time' : time,
|
||||
'_init_dict' : self._init_dict,
|
||||
'partners_by_account' : self.partners_by_account,
|
||||
} )
|
||||
|
||||
report_sxw.report_sxw(
|
||||
'report.analytic_partners.print',
|
||||
'account.analytic.account',
|
||||
'addons/analytic_partners/report/analytic_account_partners.rml',
|
||||
parser=analytic_partners_report)
|
|
@ -1 +0,0 @@
|
|||
import audittrail
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"name" : "Audit Trail",
|
||||
"website" : "http://tinyerp.com",
|
||||
"author" : "Tiny",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base"],
|
||||
"init_xml" : [],
|
||||
"description": "Allows the administrator to track every user operations on all objects of the system.",
|
||||
"category" : "Generic Modules/Others",
|
||||
"update_xml" : ["audittrail_view.xml"],
|
||||
"demo_xml" : ["audittrail_demo.xml"],
|
||||
"active" : False,
|
||||
"installable": False
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
# -*- coding :utf-8 -*-
|
||||
|
||||
from osv import osv, fields
|
||||
import time, pooler, copy
|
||||
|
||||
class audittrail_rule(osv.osv):
|
||||
_name = 'audittrail.rule'
|
||||
_columns = {
|
||||
"name": fields.char("Rule Name", size=32, required=True),
|
||||
"object_id": fields.many2one('ir.model', 'Object', required=True),
|
||||
"user_id": fields.many2many('res.users', 'audittail_rules_users', 'user_id', 'rule_id', 'Users'),
|
||||
"log_read": fields.boolean("Log reads"),
|
||||
"log_write": fields.boolean("Log writes"),
|
||||
"log_unlink": fields.boolean("Log deletes"),
|
||||
"log_create": fields.boolean("Log creates"),
|
||||
"state": fields.selection((("draft", "Draft"),("subscribed", "Subscribed")), "State", required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda *a: 'draft',
|
||||
'log_create': lambda *a: 1,
|
||||
'log_unlink': lambda *a: 1,
|
||||
'log_write': lambda *a: 1,
|
||||
}
|
||||
__functions = {}
|
||||
|
||||
def subscribe(self, cr, uid, ids, *args):
|
||||
for thisrule in self.browse(cr, uid, ids):
|
||||
obj = self.pool.get(thisrule.object_id.model)
|
||||
if not obj:
|
||||
print ("%s WARNING:audittrail:%s is not part of the pool -- change audittrail depends -- setting rule: %s as DRAFT" % (time.strftime('%a, %d %b %Y %H:%M:%S'), thisrule.object_id.model, thisrule.name))
|
||||
self.write(cr, uid, ids, {"state": "draft"})
|
||||
return False
|
||||
for field in ('read','write','create','unlink'):
|
||||
if getattr(thisrule, 'log_'+field):
|
||||
# backup corresponding method
|
||||
self.__functions.setdefault(thisrule.id, [])
|
||||
self.__functions[thisrule.id].append( (obj, field, getattr(obj,field)) )
|
||||
uids_to_log = []
|
||||
for user in thisrule.user_id:
|
||||
uids_to_log.append(user.id)
|
||||
# override it with the logging variant
|
||||
setattr(obj, field, self.logging_fct(getattr(obj,field), thisrule.object_id, uids_to_log))
|
||||
self.write(cr, uid, ids, {"state": "subscribed"})
|
||||
return True
|
||||
|
||||
def logging_fct(self, fct_src, object, logged_uids):
|
||||
if object.model=="audittrail.log":
|
||||
return fct_src
|
||||
def my_fct( cr, uid, *args, **args2):
|
||||
if not len(logged_uids) or uid in logged_uids:
|
||||
self.pool.get('audittrail.log').create(cr, uid, {"method": fct_src.__name__, "object_id": object.id, "user_id": uid, "args": "%s, %s" % (str(args), str(args2)), "name": "%s %s %s" % (fct_src.__name__, object.id, time.strftime("%Y-%m-%d %H:%M:%S"))})
|
||||
return fct_src( cr, uid, *args, **args2)
|
||||
return my_fct
|
||||
|
||||
def unsubscribe(self, cr, uid, ids, *args):
|
||||
for thisrule in self.browse(cr, uid, ids):
|
||||
for function in self.__functions[thisrule.id]:
|
||||
setattr(function[0], function[1], function[2])
|
||||
self.write(cr, uid, ids, {"state": "draft"})
|
||||
return True
|
||||
|
||||
# def __init__(self, *args):
|
||||
# super(audittrail_rule, self).__init__(*args)
|
||||
# cr = pooler.db.cursor()
|
||||
#FIXME: ah merde, ca craint pour le multi-db! Une solution serait d'overrider d'office toutes les methodes
|
||||
# et de checker dans la methode elle meme s'il faut logger ou pas, mais ca risque de tout faire ramer violemment
|
||||
# une autre solution (bien meilleure, il me semble) est de rajouter une méthode "db_dependant_init" dans osv qui est overridable
|
||||
# et appellée dans le __init__ de osv (comme creation des tables et chargement des données)
|
||||
# a merde, ca marche pas, vu que plusieurs utilisateurs peuvent etre sur des bases differentes en meme temps
|
||||
# self.subscribe(cr, 1, self.search(cr, 1, [('state','=','subscribed')]))
|
||||
# cr.commit()
|
||||
# cr.close()
|
||||
# del cr
|
||||
|
||||
class audittrail_log(osv.osv):
|
||||
_name = 'audittrail.log'
|
||||
_columns = {
|
||||
"name": fields.char("Name", size=32),
|
||||
"object_id": fields.many2one('ir.model', 'Object'),
|
||||
"user_id": fields.many2one('res.users', 'User'),
|
||||
"method": fields.selection((('read', 'Read'), ('write', 'Write'), ('unlink', 'Delete'), ('create', 'Create')), "Method"),
|
||||
"args": fields.text("Arguments"),
|
||||
"timestamp": fields.datetime("Timestamp")
|
||||
}
|
||||
_defaults = {
|
||||
"timestamp": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
}
|
||||
|
||||
audittrail_log()
|
||||
audittrail_rule()
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
<record model="audittrail.rule" id="demo_audittrail_rule">
|
||||
<field name="name">Audit on Partners</field>
|
||||
<field name="object_id" search="[('model','=','res.partner')]"/>
|
||||
<field name="user_id" search="[]"/>
|
||||
</record>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,92 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_audittrail_rule_form">
|
||||
<field name="name">audittrail.rule.form</field>
|
||||
<field name="model">audittrail.rule</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="AuditTrail Rule">
|
||||
<field name="name" select="1" required="1"/>
|
||||
<field name="object_id" select="1"/>
|
||||
<field name="log_read" />
|
||||
<field name="log_write" />
|
||||
<field name="log_unlink" />
|
||||
<field name="log_create" />
|
||||
<field name="user_id" select="1" colspan="4"/>
|
||||
<field name="state" select="1" readonly="1" />
|
||||
<group colspan="2" col="2">
|
||||
<button string="Subscribe" name="subscribe" type="object" states="draft"/>
|
||||
<button string="UnSubscribe" name="unsubscribe" type="object" states="subscribed"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_audittrail_rule_tree">
|
||||
<field name="name">audittrail.rule.tree</field>
|
||||
<field name="model">audittrail.rule</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="AuditTrail Rules">
|
||||
<field name="name" />
|
||||
<field name="object_id" />
|
||||
<field name="user_id" />
|
||||
<field name="log_read" />
|
||||
<field name="log_write" />
|
||||
<field name="log_unlink" />
|
||||
<field name="log_create" />
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_audittrail_rule_tree">
|
||||
<field name="res_model">audittrail.rule</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_audittrail_rule_form" />
|
||||
</record>
|
||||
<menuitem name="Administration/Audittrails/Rules" id="menu_action_audittrail_rule_tree" action="action_audittrail_rule_tree"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_audittrail_rule_tree_sub">
|
||||
<field name="res_model">audittrail.rule</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','subscribed')]</field>
|
||||
</record>
|
||||
<menuitem name="Administration/Audittrails/Rules/Subscribed Rules" id="menu_action_audittrail_rule_tree_sub" action="action_audittrail_rule_tree_sub"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_audittrail_log_form">
|
||||
<field name="name">audittrail.log.form</field>
|
||||
<field name="model">audittrail.log</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="AuditTrail Logs">
|
||||
<field name="timestamp" select="1" required="1" readonly="1"/>
|
||||
<field name="object_id" select="1" readonly="1"/>
|
||||
<field name="method" select="1" readonly="1"/>
|
||||
<field name="user_id" select="1" readonly="1"/>
|
||||
<field name="args" select="1" readonly="1" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_audittrail_log_tree">
|
||||
<field name="name">audittrail.log.tree</field>
|
||||
<field name="model">audittrail.log</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="AuditTrail Logs">
|
||||
<field name="timestamp" />
|
||||
<field name="object_id" />
|
||||
<field name="method" />
|
||||
<field name="user_id" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_audittrail_log_tree">
|
||||
<field name="res_model">audittrail.log</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem name="Administration/Audittrails/Logs" id="menu_action_audittrail_log_tree" action="action_audittrail_log_tree"/>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,31 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: partner.py 1007 2005-07-25 13:18:09Z kayhman $
|
||||
#
|
||||
# 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 partner_relation
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"name" : "Partners - relation extension",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"category" : "Generic Modules/CRM & SRM",
|
||||
"description" : """Add a tab in the partner form to encode relations between several partners.
|
||||
For eg, the partner 'Toubib and Co.' has different contacts.
|
||||
When 'Toubib and Co.' orders, you have to deliver to 'Toubib - Belgium'
|
||||
and invoice to 'Toubib - Geneva'.
|
||||
""",
|
||||
"depends" : ["base"],
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
"partner_relation_view.xml",
|
||||
],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: partner.py 1007 2005-07-25 13:18:09Z kayhman $
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields,osv
|
||||
|
||||
class res_partner_relation(osv.osv):
|
||||
_description='The partner object'
|
||||
_name = "res.partner.relation"
|
||||
_columns = {
|
||||
'name': fields.selection( [ ('default','Default'),('invoice','Invoice'), ('delivery','Delivery'), ('contact','Contact'), ('other','Other') ],'Relation Type', required=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Main Partner', required=True, ondelete='cascade'),
|
||||
'relation_id': fields.many2one('res.partner', 'Relation Partner', required=True, ondelete='cascade')
|
||||
}
|
||||
_defaults = {
|
||||
'name' : lambda *a: 'invoice',
|
||||
}
|
||||
res_partner_relation()
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_description='The partner object'
|
||||
_inherit = "res.partner"
|
||||
_columns = {
|
||||
'relation_ids': fields.one2many('res.partner.relation', 'partner_id', 'Relations')
|
||||
}
|
||||
|
||||
def _is_related_to(self, cr, uid, ids, toid):
|
||||
related=[]
|
||||
for id in ids:
|
||||
cr.execute("select id from res_partner_relation where (partner_id=%s and relation_id=%s) or (partner_id=%s and relation_id=%s)" % (id,toid,toid,id))
|
||||
res=cr.fetchone()
|
||||
if res and len(res):
|
||||
related.append(True)
|
||||
else:
|
||||
related.append(False)
|
||||
return related
|
||||
|
||||
def address_get(self, cr, uid, ids, adr_pref=['default']):
|
||||
todo = []
|
||||
result = {}
|
||||
cr.execute('select name,relation_id from res_partner_relation where partner_id in ('+','.join(map(str,ids))+')')
|
||||
adrs = dict(cr.fetchall())
|
||||
for adr in adr_pref:
|
||||
if adr in adrs:
|
||||
adr_prov = super(res_partner, self).address_get(cr, uid, [adrs[adr]], [adr]).values()[0]
|
||||
result[adr] = adr_prov
|
||||
else:
|
||||
todo.append(adr)
|
||||
if len(todo):
|
||||
result.update(super(res_partner, self).address_get(cr, uid, ids, todo))
|
||||
return result
|
||||
res_partner()
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<!--
|
||||
Partner Relations
|
||||
-->
|
||||
|
||||
<record model="ir.ui.view" id="view_partner_relation_form">
|
||||
<field name="name">res.partner.relation.form</field>
|
||||
<field name="model">res.partner.relation</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Relations">
|
||||
<field name="name" />
|
||||
<newline/>
|
||||
<field name="relation_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_partner_relation_tree">
|
||||
<field name="name">res.partner.relation.tree</field>
|
||||
<field name="model">res.partner.relation</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Relations">
|
||||
<field name="name" />
|
||||
<field name="relation_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Partners Extension
|
||||
-->
|
||||
|
||||
<record model="ir.ui.view" id="view_partner_form">
|
||||
<field name="name">res.partner.form.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<notebook>
|
||||
<page string="Relations">
|
||||
<field name="relation_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,29 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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 partner_sequence
|
|
@ -1,21 +0,0 @@
|
|||
#
|
||||
# Use the custom module to put your specific code in a separate module.
|
||||
#
|
||||
{
|
||||
"name" : "Add an automatic sequence on partners",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"category" : "Generic Modules/Base",
|
||||
"website": "http://www.tinyerp.com",
|
||||
"depends" : ["base"],
|
||||
"description": """
|
||||
This module adds the possibility to define a sequence for
|
||||
the partner code. This code is then set as default when you
|
||||
create a new partner, using the defined sequence.
|
||||
""",
|
||||
"demo_xml" : [],
|
||||
"init_xml" : ['partner_sequence.xml'],
|
||||
"update_xml" : [],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
class partner_sequence(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
def create(self, cr, uid, vals, context={}):
|
||||
vals['ref'] = self.pool.get('ir.sequence').get(cr, uid, 'res.partner')
|
||||
res = super(partner_sequence, self).create(cr, uid, vals, context)
|
||||
return res
|
||||
_columns = {
|
||||
'ref': fields.char('Code', size=64, readonly=True),
|
||||
}
|
||||
partner_sequence()
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
|
||||
#
|
||||
# Sequences for res.partner
|
||||
#
|
||||
|
||||
<record model="ir.sequence.type" id="seq_type_res_partner">
|
||||
<field name="name">Partner code</field>
|
||||
<field name="code">res.partner</field>
|
||||
</record>
|
||||
<record model="ir.sequence" id="seq_res_partner">
|
||||
<field name="name">Partner code</field>
|
||||
<field name="code">res.partner</field>
|
||||
<field name="prefix">P/</field>
|
||||
<field name="padding">5</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,36 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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 sale_cust_price
|
||||
import partner
|
||||
|
||||
from edi import *
|
||||
|
||||
import wizard
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"name" : "EDI",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"depends" : ["sale"],
|
||||
"category" : "Interfaces/EDI",
|
||||
'description': "Used for the communication with others proprietary ERP's. Has been tested in the food industries process, communicating with SAP. This module is able to import order and export delivery notes.",
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ["edi_wizard.xml", "edi_view.xml", "edi_data.xml", "sale_cust_price.xml"],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
À mettre dans /edi/reception !
|
||||
|
||||
Ajouter les EAN aux partenaires et aux produits et le packaging
|
||||
|
||||
Commandes SQL pour les menus:
|
||||
|
||||
* Produit qui disparaissent :
|
||||
UPDATE ir_ui_menu SET parent_id = 169 WHERE id = 172
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
import time
|
||||
import netsvc
|
||||
from osv import fields,osv,orm
|
||||
import ir
|
||||
from mx import DateTime
|
||||
|
||||
|
||||
class edi_log(osv.osv):
|
||||
_name = "edi.log"
|
||||
_description = "EDI log"
|
||||
_columns = { 'name': fields.char('Log name', size=32, required=True),
|
||||
'log_line': fields.one2many('edi.log.line', 'log_id', 'Log Lines', readonly=True, states={'draft':[('readonly', False)]}),
|
||||
}
|
||||
|
||||
_defaults = { 'name': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
}
|
||||
|
||||
edi_log()
|
||||
|
||||
|
||||
class edi_log_line(osv.osv):
|
||||
_name = "edi.log.line"
|
||||
_description = "EDI Log Line"
|
||||
_columns = { 'log_id': fields.many2one('edi.log', 'Log Ref'),
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'logdesc': fields.text('Description'),
|
||||
'sender': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
'timestamp': fields.char('Order date', size=13),
|
||||
'order_num': fields.char('Edi Order Id', size=15),
|
||||
}
|
||||
_defaults = { 'name': lambda *a: 'logline',
|
||||
}
|
||||
|
||||
edi_log_line()
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
<record id="edi_request" model="res.request.link">
|
||||
<field name="name">EDI Log</field>
|
||||
<field name="object">edi.log</field>
|
||||
</record>
|
||||
|
||||
<record model="product.pricelist.type" id="pricelist_type_sale">
|
||||
<field name="name">Customer Pricelist</field>
|
||||
<field name="key">edi_customer</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.property" id="property_product_pricelist_customer" forcecreate="True">
|
||||
<field name="name">property_product_pricelist_customer</field>
|
||||
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_product_pricelist_customer')]"/>
|
||||
<field name="value" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_edi_log_line">
|
||||
<field name="name">edi.log.line.tree</field>
|
||||
<field name="model">edi.log.line</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="order_num"/>
|
||||
<field name="timestamp"/>
|
||||
<field name="sender"/>
|
||||
<field name="logdesc"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_edi_tree">
|
||||
<field name="name">edi.log.tree</field>
|
||||
<field name="model">edi.log</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="EDI Logs">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_edi_form">
|
||||
<field name="name">edi.log.form</field>
|
||||
<field name="model">edi.log</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="EDI Logs">
|
||||
<field name="name" select="1"/>
|
||||
<newline/>
|
||||
<field name="log_line" widget="one2many_list" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_edi_tree">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">edi.log</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" eval="False" />
|
||||
</record>
|
||||
<menuitem name="Sales Management/Edi/View Logs" action="action_edi_tree" id="menu_edi_log"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<wizard string="Import EDI Sales" model="sale.order" name="edi.import" id="wizard_edi_import"/>
|
||||
<menuitem name="Sales Management/Edi/Import Edi Sales Orders" action="wizard_edi_import" type="wizard"/>
|
||||
<wizard string="Export EDI Sales" model="sale.order" name="edi.import" id="wizard_edi_export"/>
|
||||
<menuitem name="Sales Management/Edi/Export Edi Sales Orders" action="wizard_edi_export" type="wizard"/>
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_name = 'res.partner'
|
||||
_inherit = 'res.partner'
|
||||
_columns = {
|
||||
'property_product_pricelist_customer': fields.property(
|
||||
'product.pricelist',
|
||||
type='many2one',
|
||||
relation='product.pricelist',
|
||||
string="Customer Pricelist",
|
||||
method=True,
|
||||
view_load=True,
|
||||
group_name="Pricelists Properties"),
|
||||
}
|
||||
res_partner()
|
||||
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0"?>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
||||
|
||||
<xsl:template match="/">
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -1,45 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields,osv,orm
|
||||
|
||||
|
||||
class sale_order(osv.osv):
|
||||
_inherit = 'sale.order'
|
||||
_columns = {
|
||||
'customer_pricelist_id':fields.many2one('product.pricelist', 'Customer Pricelist'),
|
||||
}
|
||||
sale_order()
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
_inherit = 'sale.order.line'
|
||||
_columns = {
|
||||
'price_unit_customer': fields.float('Customer Unit Price'),
|
||||
}
|
||||
sale_order_line()
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_sale_order">
|
||||
<field name="name">sale.order.form.pvc</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="client_order_ref" position="after">
|
||||
<field name="customer_pricelist_id" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_sale_order_line">
|
||||
<field name="name">sale.order.line.form.pvc</field>
|
||||
<field name="model">sale.order.line</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="price_unit" position="after">
|
||||
<field name="price_unit_customer"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,28 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# 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_edi_import
|
|
@ -1,127 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
def stripnulls(data):
|
||||
return data.replace("\00", "").strip()
|
||||
|
||||
def fillleft(data, length):
|
||||
while len(str(data))<length:
|
||||
data=" "+str(data)
|
||||
return data
|
||||
|
||||
def fillright(data, length):
|
||||
while len(str(data))<length:
|
||||
data=str(data)+" "
|
||||
return data
|
||||
|
||||
def fillzero(data, length):
|
||||
while len(str(data))<length:
|
||||
data="0"+str(data)
|
||||
return data
|
||||
|
||||
class edi_exchange:
|
||||
|
||||
hint_struct = { "sender": ( 4, 39, stripnulls, fillright),
|
||||
"receiver": ( 57, 92, stripnulls, fillright),
|
||||
"date": ( 110, 118, stripnulls, fillright),
|
||||
"time": ( 118, 122, stripnulls, fillleft),
|
||||
}
|
||||
|
||||
hgen_struct = { "message-type": ( 32, 43, stripnulls, fillright),
|
||||
"order-num": ( 43, 78, stripnulls, fillright),
|
||||
"order-date": ( 78, 86, stripnulls, fillright),
|
||||
"currency": ( 101, 104, stripnulls, fillright),
|
||||
}
|
||||
|
||||
hpty_struct = { "partner-type": ( 4, 7, stripnulls, fillright),
|
||||
"partner-code": ( 7, 24, stripnulls, fillright),
|
||||
}
|
||||
|
||||
hdel_struct = { "deliv-date": ( 4, 12, stripnulls, fillright),
|
||||
"deliv-time": ( 12, 16, stripnulls, fillright),
|
||||
"deliv-q": ( 16, 19, stripnulls, fillright),
|
||||
}
|
||||
|
||||
hftx_struct = { "text-q": ( 4, 7, stripnulls, fillright),
|
||||
"text": ( 7, 209, stripnulls, fillright),
|
||||
}
|
||||
|
||||
dftx_struct = { "text-q": ( 4, 7, stripnulls, fillright),
|
||||
"text": ( 7, 209, stripnulls, fillright),
|
||||
}
|
||||
|
||||
dart_struct = { "line-num": ( 4, 10, stripnulls, fillzero),
|
||||
"barcode": ( 13, 48, stripnulls, fillright),
|
||||
"quantity21": ( 89, 104, stripnulls, fillzero),
|
||||
"unit21": ( 107, 110, stripnulls, fillright),
|
||||
"quantity59": ( 110, 125, stripnulls, fillzero),
|
||||
"unit59": ( 128, 131, stripnulls, fillright),
|
||||
"price": ( 131, 146, stripnulls, fillzero),
|
||||
"price-q": ( 146, 149, stripnulls, fillright),
|
||||
"price-unit": ( 149, 152, stripnulls, fillright),
|
||||
"hint-price": ( 152, 167, stripnulls, fillright),
|
||||
"hint-price-q": ( 167, 170, stripnulls, fillright),
|
||||
"hint-price-u": ( 170, 173, stripnulls, fillright),
|
||||
"ref86": ( 173, 181, stripnulls, fillright),
|
||||
"shop-code": ( 181, 196, stripnulls, fillright),
|
||||
"item-key": ( 196, 209, stripnulls, fillright),
|
||||
"shop-key": ( 209, 215, stripnulls, fillright),
|
||||
"log-unit-num": ( 215, 220, stripnulls, fillright),
|
||||
}
|
||||
|
||||
dpty_struct = { "shop-barcode": ( 7, 24, stripnulls, fillright),
|
||||
}
|
||||
|
||||
ddel_struct = { "deliv-date": ( 4, 12, stripnulls, fillright),
|
||||
"deliv-time": ( 12, 16, stripnulls, fillright),
|
||||
}
|
||||
|
||||
dpid_struct = { "ident-art": ( 7, 42, stripnulls, fillright),
|
||||
}
|
||||
|
||||
def parse_line(cls, line):
|
||||
lineDict = {}
|
||||
if hasattr(cls,line[:4].lower()+"_struct"):
|
||||
for field, tuple in getattr(cls,line[:4].lower()+"_struct").items():
|
||||
start, end, parseFunc, writeFunc = tuple
|
||||
lineDict[field] = parseFunc(line[start:end])
|
||||
return line[:4], lineDict
|
||||
else:
|
||||
return line[:4], {}
|
||||
|
||||
parse_line = classmethod(parse_line)
|
||||
|
||||
def create_line(cls, line):
|
||||
lineDict = {}
|
||||
outline=line['type'].upper()+" "*250+"\r\n"
|
||||
if hasattr(cls,line['type'].lower()+"_struct"):
|
||||
for field, tuple in getattr(cls, line['type'].lower()+"_struct").items():
|
||||
start, end, parseFunc, writeFunc = tuple
|
||||
outline=outline[0:start]+writeFunc(line[field], end-start)+outline[end:]
|
||||
return outline
|
||||
|
||||
create_line = classmethod(create_line)
|
|
@ -1,69 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: wizard_edi_export.py 2071 2006-01-09 16:37:25Z nicoe $
|
||||
#
|
||||
# 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
|
||||
|
||||
_export_form = '''<?xml version="1.0"?>
|
||||
<form string="EDI file export">
|
||||
<separator string="Export to the following directory" colspan="4" />
|
||||
<field name="ediexportdir" colspan="4" />
|
||||
</form>'''
|
||||
|
||||
_export_fields = { 'ediexportdir' : { 'string' : 'EDI Import Dir',
|
||||
'type' : 'char',
|
||||
'size' : 100,
|
||||
'default' : lambda *a: '/edi/reception',
|
||||
'required' : True
|
||||
},
|
||||
}
|
||||
|
||||
_export_done_form = '''<?xml version="1.0"?>
|
||||
<form string="EDI file exported">
|
||||
<separator string="EDI file exported" colspan="4" />
|
||||
</form>'''
|
||||
|
||||
_export_done_fields = {}
|
||||
|
||||
def _do_export(self, cr, uid, data, context):
|
||||
return {}
|
||||
|
||||
class wiz_edi_export(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'result' : { 'type' : 'form', 'arch' : _import_form, 'fields' : _import_fields, 'state' : (('end', 'Cancel'),('export', 'Export Sales') )},
|
||||
},
|
||||
'export' : {
|
||||
'actions' : [_do_export],
|
||||
'result' : { 'type' : 'form', 'arch' : _export_done_form, 'fields' : _export_done_fields, 'state' : (('end', 'Ok'),)},
|
||||
},
|
||||
}
|
||||
|
||||
wiz_edi_export('edi.export')
|
||||
# vim:noexpandtab:
|
|
@ -1,488 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: wizard_edi_import.py 1825 2005-12-13 11:04:20Z ede $
|
||||
#
|
||||
# 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 ir
|
||||
import time
|
||||
import os
|
||||
from edi_exchange import edi_exchange
|
||||
|
||||
import wizard
|
||||
from osv import osv
|
||||
import pooler
|
||||
|
||||
_import_form = '''<?xml version="1.0"?>
|
||||
<form string="EDI file import">
|
||||
<separator string="Import the following files" colspan="4" />
|
||||
<field name="ediimportdir" colspan="4" />
|
||||
<field name="current" />
|
||||
<field name="error" />
|
||||
</form>'''
|
||||
|
||||
_import_fields = { 'ediimportdir' : { 'string' : 'EDI Import Dir',
|
||||
'type' : 'char',
|
||||
'size' : 100,
|
||||
'default' : lambda *a: '/edi/reception',
|
||||
'required' : True
|
||||
},
|
||||
'current' : { 'string' : 'Current',
|
||||
'type' : 'boolean',
|
||||
'default' : lambda *a: True,
|
||||
},
|
||||
'error' : { 'string' : 'Error',
|
||||
'type' : 'boolean',
|
||||
'default' : lambda *a: False,
|
||||
},
|
||||
}
|
||||
|
||||
_import_done_form = '''<?xml version="1.0"?>
|
||||
<form string="EDI file imported">
|
||||
<separator string="EDI file imported" colspan="4" />
|
||||
</form>'''
|
||||
|
||||
_import_done_fields = {}
|
||||
|
||||
def _child_of_partner(cr, uid, child, parent):
|
||||
if child==parent:
|
||||
return True
|
||||
direct_parent_list=pooler.get_pool(cr.dbname).get('res.partner').read(cr, uid, [child], ['parent_id'])
|
||||
#print str(direct_parent_list)
|
||||
if len(direct_parent_list)!=1:
|
||||
return False
|
||||
if not direct_parent_list[0]['parent_id']:
|
||||
return False
|
||||
direct_parent=direct_parent_list[0]['parent_id'][0]
|
||||
if direct_parent and direct_parent!='':
|
||||
return _child_of_partner( cr, uid, direct_parent, parent)
|
||||
else:
|
||||
return False
|
||||
|
||||
def _prepare_import(self, cr, uid, data, context):
|
||||
files=[]
|
||||
for (type, dir) in [('current', 'encours'), ('error', 'erreur')]:
|
||||
if (data['form'][type]):
|
||||
edi_path = os.path.join(data['form']['ediimportdir'], dir)
|
||||
if not os.path.isdir(edi_path):
|
||||
os.makedirs(edi_path)
|
||||
for file in os.listdir(edi_path):
|
||||
#print file[:9]
|
||||
if file[:9]=="COMMANDE.":
|
||||
files.append((file, os.path.join(data['form']['ediimportdir'], dir, file)))
|
||||
for (filename, file) in files:
|
||||
#print "Importing %s" % filename
|
||||
FirstInt=True
|
||||
FirstOrd=True
|
||||
sr = {'sender':None, 'receiver':None}
|
||||
sale_orders = []
|
||||
log_id=pooler.get_pool(cr.dbname).get('edi.log').create(cr, uid, {})
|
||||
logline=pooler.get_pool(cr.dbname).get('edi.log.line')
|
||||
logline.create(cr, uid, {
|
||||
'log_id': log_id,
|
||||
'logdesc': "Checking %s" % filename,
|
||||
})
|
||||
try:
|
||||
status= edi_status()
|
||||
fh = open(file, "r")
|
||||
for line in fh:
|
||||
line_type, line_content = edi_exchange.parse_line(line)
|
||||
if line_type == "HINT":
|
||||
if not FirstInt:
|
||||
sale_orders.append(sale_order_o)
|
||||
FirstOrd=True
|
||||
sale_order_o = sale_order(cr, uid, sr)
|
||||
elif line_type == "HPTY":
|
||||
if not FirstOrd:
|
||||
FirstInt=False
|
||||
elif line_type == "DART":
|
||||
FirstOrd=False
|
||||
|
||||
sale_order_o.parse_line(line_type, line_content, status)
|
||||
|
||||
sale_orders.append(sale_order_o)
|
||||
|
||||
finally:
|
||||
fh.close()
|
||||
|
||||
for (order_id, order_timestamp, sender, message) in status.messages:
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "\t%s" % message,
|
||||
'timestamp': order_timestamp,
|
||||
'order_num': order_id
|
||||
})
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Messages:%s\tErrors:%s\tWarnings:%s" % (len(status.messages), status.error_count, status.warning_count),
|
||||
})
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Finished Checking %s" % filename,
|
||||
})
|
||||
|
||||
if status.error_count==0:
|
||||
print "Integrating %s" % filename
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Importing %s" % filename,
|
||||
})
|
||||
for order in sale_orders:
|
||||
order.store()
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Import Finished",
|
||||
})
|
||||
if not os.path.isdir(os.path.join(data['form']['ediimportdir'],'archive')):
|
||||
os.mkdir(os.path.join(data['form']['ediimportdir'],'archive'))
|
||||
os.rename(file, os.path.join(data['form']['ediimportdir'],'archive', filename))
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Moved %s to archive" % filename,
|
||||
})
|
||||
else:
|
||||
ids=pooler.get_pool(cr.dbname).get('res.users').search(cr,1, [('roles_id', 'ilike', 'EDI')])
|
||||
for id in ids:
|
||||
pooler.get_pool(cr.dbname).get('res.request').create(cr, uid, { 'act_to': id,
|
||||
'name' : "Error while importing %s" % filename,
|
||||
'ref_doc1' : "edi.log,%s" % log_id,
|
||||
'state' : 'active',
|
||||
})
|
||||
try:
|
||||
os.rename(file, os.path.join(data['form']['ediimportdir'],'erreur', filename))
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Moved %s to erreur" % filename,
|
||||
})
|
||||
except:
|
||||
logline.create(cr, uid, { 'log_id': log_id,
|
||||
'logdesc': "Couldn't move %s to erreur" % filename,
|
||||
})
|
||||
cr.commit()
|
||||
return {}
|
||||
|
||||
def _do_import(self, cr, uid, data, context):
|
||||
pass
|
||||
|
||||
class wiz_edi_import(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'result' : { 'type' : 'form', 'arch' : _import_form, 'fields' : _import_fields, 'state' : [('end', 'Cancel'),('check', 'Check EDI')]},
|
||||
},
|
||||
'check' : {
|
||||
'actions' : [ _prepare_import ],
|
||||
# 'result' : { 'type' : 'print', 'report' : 'edi.import-results', 'state' : [('do_import', 'Import EDI'), ('end', 'End')] },
|
||||
'result' : { 'type' : 'form', 'arch' : _import_done_form, 'fields': _import_done_fields, 'state' : [('end','end')]},
|
||||
},
|
||||
'do_import' : {
|
||||
'actions' : [ _do_import ],
|
||||
'result' : { 'type' : 'form', 'arch' : _import_done_form, 'fields' : _import_done_fields, 'state' : [('end','end')]},
|
||||
},
|
||||
}
|
||||
|
||||
class sale_order:
|
||||
|
||||
def __init__(self, cr, uid, sr):
|
||||
self.cr=cr
|
||||
self.uid=uid
|
||||
self.shop_id=pooler.get_pool(cr.dbname).get('sale.shop').search(cr, uid, [])[0]
|
||||
self.pricelist_id = None
|
||||
self.order_lines=[]
|
||||
self.partner_id=sr['sender']
|
||||
self.partner_order_id=0
|
||||
self.partner_invoice_id=0
|
||||
self.sr = sr
|
||||
self.timesatmp_edi=time.strftime('%Y%m%d%H%M')
|
||||
self.ordernum = '0'
|
||||
self.deliverdate=None
|
||||
self.note = ''
|
||||
|
||||
def store(self):
|
||||
if not hasattr(self, 'partner_invoice_id'):
|
||||
self.partner_invoice_id = self.partner_id
|
||||
if not hasattr(self, 'partner_shipping_id'):
|
||||
self.partner_shipping_id = self.partner_invoice_id
|
||||
order_id = pooler.get_pool(cr.dbname).get('sale.order').create(self.cr, self.uid, { 'partner_id': self.partner_id,
|
||||
'partner_order_id': self.partner_order_id,
|
||||
'partner_invoice_id': self.partner_invoice_id,
|
||||
'partner_shipping_id': self.partner_shipping_id,
|
||||
'shop_id': self.shop_id,
|
||||
'pricelist_id': self.pricelist_id,
|
||||
'client_order_ref': self.ordernum,
|
||||
'date_order': self.orderdate,
|
||||
'note': self.note,
|
||||
})
|
||||
for orderline in self.order_lines:
|
||||
orderline.store(order_id)
|
||||
|
||||
def addline(self, line):
|
||||
self.orderlines.append(line)
|
||||
|
||||
def parse_line(self, line_type, line_content, status):
|
||||
if hasattr(self, "_parse_%s" % line_type):
|
||||
myFct=getattr(self, "_parse_%s" % line_type)
|
||||
myFct(line_content, status)
|
||||
else:
|
||||
status.add_warning("ignoring line type: %s" % line_type, self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HINT(self, line_content, status):
|
||||
self.timestamp_edi="%s%s" % (line_content["date"], line_content["time"])
|
||||
self.sr['sender'] = line_content['sender']
|
||||
|
||||
partners=pooler.get_pool(cr.dbname).get('res.partner').search(self.cr, self.uid, [('ean13','=',line_content["receiver"]),])
|
||||
if len(partners) != 1:
|
||||
status.add_error("unknown receiver: %s" % line_content["receiver"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
self.sr['receiver']=partners[0]
|
||||
thisadd=pooler.get_pool(cr.dbname).get('res.users').read(self.cr, self.uid, [self.uid], ['address_id'])[0]['address_id'][0]
|
||||
partner=pooler.get_pool(cr.dbname).get('res.partner.address').read(self.cr, self.uid, [thisadd], ['partner_id'])[0]['partner_id'][0]
|
||||
if not partner or partner!=self.sr['receiver']:
|
||||
status.add_error("This message is not for us (%s)" % line_content["receiver"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HGEN(self, line_content, status):
|
||||
if line_content["order-num"]=='':
|
||||
status.add_error("No client order reference", self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
self.ordernum=line_content["order-num"]
|
||||
self.orderdate=line_content["order-date"]
|
||||
if line_content["message-type"]!="ORDERS93A" and line_content["message-type"]!="ORDERS96A" and line_content["message-type"]!="GENCOD02303" and line_content["message-type"]!="GENCOD08604":
|
||||
status.add_error("Unknown message type %s" % line_content["message-type"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HDEL(self, line_content, status):
|
||||
if (not self.deliverdate or self.deliverdate > line_content['deliv-date']) and line_content['deliv-q'] in ('137', '200'):
|
||||
self.deliverdate = line_content['deliv-date']
|
||||
if self.deliverdate < self.orderdate:
|
||||
status.add_error("%s (order date) is after %s (delivery date)" % (self.orderdate,self.deliverdate), self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HPTY(self, line_content, status):
|
||||
partner_table = pooler.get_pool(cr.dbname).get('res.partner')
|
||||
|
||||
partners = partner_table.search(self.cr, self.uid, [('ean13', '=', line_content['partner-code'])])
|
||||
if partners and len(partners) == 1:
|
||||
default_addresses = pooler.get_pool(cr.dbname).get('res.partner.address').search(self.cr, self.uid, [('partner_id', '=', partners[0]), ('type', 'ilike', 'default')])
|
||||
if not default_addresses:
|
||||
default_addresses = pooler.get_pool(cr.dbname).get('res.partner.address').search(self.cr, self.uid, [('partner_id', '=', partners[0]), ('type', 'ilike', '')])
|
||||
if not default_addresses:
|
||||
default_addresses = pooler.get_pool(cr.dbname).get('res.partner.address').search(self.cr, self.uid, [('partner_id', '=', partners[0])])
|
||||
self.hpty_dispatchers[line_content['partner-type']](self, partners[0], default_addresses, line_content, status)
|
||||
else:
|
||||
status.add_error("unknown %s: %s" % (line_content["partner-type"], line_content["partner-code"]), self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HPTYBY(self, partner, default_addresses, line_content, status):
|
||||
partner_table = pooler.get_pool(cr.dbname).get('res.partner')
|
||||
|
||||
self.sr['sender'] = partner
|
||||
self.partner_id = partner
|
||||
self.partner_order_id = default_addresses[0]
|
||||
self.pricelist_id = ir.ir_get(self.cr, self.uid, 'meta', 'product.pricelist', [('res.partner', self.partner_id)])[0][2]
|
||||
orders=pooler.get_pool(cr.dbname).get("sale.order").search(self.cr, self.uid, [('client_order_ref', 'ilike', self.ordernum), ('partner_order_id',"=",self.partner_order_id)])
|
||||
if orders and len(orders)>0:
|
||||
status.add_warning("This client order reference (%s) already exists for this client" % self.ordernum, self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HPTYSU(self, partner, default_addresses, line_content, status):
|
||||
partner_table = pooler.get_pool(cr.dbname).get('res.partner')
|
||||
if not (partner_table._is_related_to(self.cr, self.uid, [partner], self.sr['receiver'])[0] or self.sr['receiver'] == partner):
|
||||
status.add_error("unknown %s: %s" % (line_content["partner-type"], line_content["partner-code"]), self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
|
||||
def _parse_HPTYDP(self, partner, default_addresses, line_content, status):
|
||||
shipping_addresses=pooler.get_pool(cr.dbname).get('res.partner.address').search(self.cr, self.uid, [('partner_id','=',partner), ('type', 'ilike', 'delivery')])
|
||||
if len(shipping_addresses) < 1:
|
||||
self.partner_shipping_id=default_addresses[0]
|
||||
else:
|
||||
self.partner_shipping_id=shipping_addresses[0]
|
||||
|
||||
invoice_addresses=pooler.get_pool(cr.dbname).get('res.partner.address').search(self.cr, self.uid, [('partner_id','=',partner), ('type', 'ilike', 'invoice')])
|
||||
if len(invoice_addresses) < 1:
|
||||
self.partner_invoice_id=default_addresses[0]
|
||||
else:
|
||||
self.partner_invoice_id=invoice_addresses[0]
|
||||
|
||||
def _parse_HPTYIV(self, partner, default_addresses, line_content, status):
|
||||
invoice_addresses=pooler.get_pool(cr.dbname).get('res.partner.address').search(self.cr, self.uid, [('partner_id','=',partner), ('type', 'ilike', 'invoice')])
|
||||
if len(invoice_addresses) < 1:
|
||||
self.partner_invoice_id=default_addresses[0]
|
||||
else:
|
||||
self.partner_invoice_id=invoice_addresses[0]
|
||||
|
||||
hpty_dispatchers = { 'BY' : _parse_HPTYBY, 'SU' : _parse_HPTYSU, 'DP' : _parse_HPTYDP, 'IV' : _parse_HPTYIV }
|
||||
|
||||
def _parse_HFTX(self, line_content, status):
|
||||
self.note+=line_content['text']+'\n'
|
||||
|
||||
def _parse_DART(self, line_content, status):
|
||||
products=pooler.get_pool(cr.dbname).get('product.product').search(self.cr, self.uid, [('ean13','=',line_content["barcode"]),])
|
||||
#sale_order_line_o=sale_order_line(self.cr, self.uid, self.deliverdate, self.partner_invoice_id, status)
|
||||
sale_order_line_o=sale_order_line(self.cr, self.uid, self, self.deliverdate)
|
||||
if len(products) != 1:
|
||||
status.add_error("unknown product: %s" % line_content["barcode"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
return
|
||||
else:
|
||||
sale_order_line_o.product=products[0]
|
||||
sale_order_line_o.product_ean=line_content["barcode"]
|
||||
if (line_content["unit21"]==''):
|
||||
status.add_warning("Using default Unit Of Measure", self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
uoms=pooler.get_pool(cr.dbname).get('product.uom').search(self.cr, self.uid, [('name', 'ilike', line_content["unit21"]),])
|
||||
if len(uoms) != 1:
|
||||
status.add_error("unknown uom: %s" % line_content["unit21"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
return
|
||||
else:
|
||||
sale_order_line_o.uom=uoms[0]
|
||||
sale_order_line_o.quantity=float(line_content["quantity21"])
|
||||
sale_order_line_o.uoc_quantity=float(line_content["quantity59"])
|
||||
sale_order_line_o.lineid=line_content["line-num"]
|
||||
sale_order_line_o.partner_address=None
|
||||
sale_order_line_o.price=line_content["price"]
|
||||
if sale_order_line_o.partner==0:
|
||||
partner=self.partner_id
|
||||
else:
|
||||
partner=sale_order_line_o.partner
|
||||
pricelist_id = ir.ir_get(self.cr, self.uid, 'meta', 'product.pricelist', [('res.partner', partner)])[0][2]
|
||||
sale_order_line_o.price = pooler.get_pool(cr.dbname).get('product.pricelist').price_get(self.cr, self.uid, [pricelist_id], sale_order_line_o.product, sale_order_line_o.quantity)[pricelist_id]
|
||||
sale_order_line_o.pricelist_id=pricelist_id
|
||||
if float(line_content["price"])!=sale_order_line_o.price:
|
||||
status.add_warning("Price from EDI (%s) different from what we have (%s) for product %s" % (str(float(line_content["price"])), sale_order_line_o.price, line_content["barcode"]), self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
product_infos = pooler.get_pool(cr.dbname).get('product.product').read(self.cr, self.uid, [sale_order_line_o.product])[0]
|
||||
if line_content['price-unit']=="":
|
||||
status.add_warning("Blank Unit Of Price for product %s should be %s" % (line_content['barcode'], product_infos['uos_id'][1]), self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
sale_order_line_o.price_unit= product_infos['uos_id'][0]
|
||||
elif product_infos['uos_id'][1] != line_content['price-unit']:
|
||||
status.add_error('Invalid Unit Of Price for product %s Should be "%s" instead of "%s"' % (line_content['barcode'], product_infos['uos_id'][1], line_content["price-unit"]), self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
sale_order_line_o.price_unit= product_infos['uos_id'][0]
|
||||
sale_order_line_o.price_unit_customer=float(line_content['hint-price'])
|
||||
sale_order_line_o.check(status)
|
||||
self.order_lines.append(sale_order_line_o)
|
||||
|
||||
def _parse_DDEL(self, line_content, status):
|
||||
sale_order_line_o = self.order_lines[len(self.order_lines)-1]
|
||||
sale_order_line_o.deliv_date = "%s%s" % (line_content["deliv-date"], line_content["deliv-time"])
|
||||
|
||||
def _parse_DPTY(self, line_content, status):
|
||||
if len(self.order_lines)<1:
|
||||
status.add_error("no DART line parsed before this DPTY line", self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
sale_order_line_o = self.order_lines[len(self.order_lines)-1]
|
||||
partners=pooler.get_pool(cr.dbname).get('res.partner').search(self.cr, self.uid, [('ean13','=',line_content["shop-barcode"]),])
|
||||
if len(partners) != 1:
|
||||
status.add_error("unknown address: %s" % line_content["shop-barcode"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
elif not _child_of_partner(self.cr, self.uid, partners[0], self.sr['sender']):
|
||||
status.add_error("unknown address: %s" % line_content["shop-barcode"], self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
sale_order_line_o.partner_address=partners[0]
|
||||
|
||||
def _parse_DPID(self, line_content, status):
|
||||
if len(self.order_lines)<1:
|
||||
status.add_error("no DART line parsed before this DPTY line", self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
sale_order_line_o = self.order_lines[len(self.order_lines)-1]
|
||||
sale_order_line_o.note+=line_content['ident-art']+'\n'
|
||||
|
||||
def _parse_DFTX(self, line_content, status):
|
||||
if len(self.order_lines)<1:
|
||||
status.add_error("no DART line parsed before this DPTY line", self.ordernum, self.timestamp_edi, self.sr['sender'])
|
||||
else:
|
||||
sale_order_line_o = self.order_lines[len(self.order_lines)-1]
|
||||
sale_order_line_o.note+=line_content['text']+'\n'
|
||||
|
||||
|
||||
class sale_order_line:
|
||||
|
||||
def __init__(self, cr, uid, sale_order_o, deliv_date):
|
||||
#, partner_address, status):
|
||||
self.cr=cr
|
||||
self.uid=uid
|
||||
self.insertdict={}
|
||||
self.partner_address=None
|
||||
if deliv_date:
|
||||
self.deliv_date=deliv_date
|
||||
self.note=''
|
||||
self.product=0
|
||||
self.sale_order= sale_order_o
|
||||
self.price_unit=0
|
||||
if sale_order_o.partner_invoice_id!=0:
|
||||
self.partner=pooler.get_pool(cr.dbname).get('res.partner.address').read(self.cr, self.uid, [sale_order_o.partner_invoice_id], ['partner_id'])[0]['partner_id'][0]
|
||||
else:
|
||||
self.partner=0
|
||||
#self.status=status
|
||||
|
||||
def check(self, status):
|
||||
self.cr.execute('select id from product_packaging where product_id=%d and qty=%f limit 1', (self.product, float(self.uoc_quantity)))
|
||||
packs = self.cr.fetchone()
|
||||
if packs is None or not len(packs):
|
||||
status.add_error('Invalid package for product %s (%s)' % (self.product_ean, float(self.uoc_quantity)), self.sale_order.ordernum, self.sale_order.timestamp_edi, self.sale_order.sr['sender'])
|
||||
else:
|
||||
self.pack_id=packs[0]
|
||||
|
||||
#print "PriceList: %s, product: %s, quantity: %s " % (self.pricelist_id, self.product, self.quantity)
|
||||
try:
|
||||
dico=pooler.get_pool(cr.dbname).get('sale.order.line').product_id_change(self.cr, self.uid, [], self.pricelist_id, self.product, int(float(self.quantity)))
|
||||
self.insertdict.update({'product_uos_qty': dico['value']['product_uos_qty'], 'product_uos': dico['value']['product_uos'][0], 'price_unit': dico['value']['price_unit']})
|
||||
except:
|
||||
status.add_error('No price defined for product %s, line ommited !' % (self.product_ean,), self.sale_order.ordernum, self.sale_order.timestamp_edi, self.sale_order.sr['sender'])
|
||||
#print str(dico)
|
||||
# Checking the unit used for the price computation
|
||||
# product_infos = pooler.get_pool(cr.dbname).get('product.product').read(self.cr, self.uid, [self.product])[0]
|
||||
# if product_infos['uos_id'][1] != self.price_unit:
|
||||
# status.add_warning('Invalid unit for Sale price : Should be "%s"' % product_infos['uos_id'][1], self.sale_order.ordernum, self.sale_order.timestamp_edi, self.sale_order.sr['sender'])
|
||||
|
||||
# Checking the price
|
||||
|
||||
# if unit_price != self.price:
|
||||
# status.add_warning('Invalid price', self.sale_order.ordernum, self.sale_order.timestamp_edi, self.sale_order.sr['sender'])
|
||||
|
||||
def store (self, order_id):
|
||||
insertdict.update( { 'order_id': order_id,
|
||||
'product_id': self.product,
|
||||
'product_uom_qty': self.quantity,
|
||||
'name': "%s%s" %(order_id, self.lineid),
|
||||
'address_allotment_id': self.partner_address,
|
||||
'notes': self.note,
|
||||
'product_packaging': self.pack_id,
|
||||
# 'unit_price': self.price_unit,
|
||||
'price_unit': self.price,
|
||||
'price_unit_customer': self.price_unit_customer,
|
||||
})
|
||||
self.unit_price=self.price
|
||||
if hasattr(self, 'uom'):
|
||||
insertdict['product_uom'] = self.uom
|
||||
else:
|
||||
insertdict['product_uom'], desc = pooler.get_pool(cr.dbname).get('product.product').read(self.cr, self.uid, [self.product], ['uom_id'])[0]['uom_id']
|
||||
if hasattr(self, 'deliv_date'):
|
||||
insertdict['date_planned'] = self.deliv_date
|
||||
id=pooler.get_pool(cr.dbname).get('sale.order.line').create(self.cr, self.uid, insertdict)
|
||||
return id
|
||||
|
||||
class edi_status:
|
||||
def __init__(self):
|
||||
self.error_count=0
|
||||
self.warning_count=0
|
||||
self.messages=[]
|
||||
|
||||
def add_error(self, message, order_id, timestamp_edi, sender):
|
||||
self.messages.append((order_id, timestamp_edi, sender, "ERROR:\t%s" % message))
|
||||
self.error_count+=1
|
||||
|
||||
def add_warning(self, message, order_id, timestamp_edi, sender):
|
||||
self.messages.append((order_id, timestamp_edi, sender, "WARNING:\t%s" % message))
|
||||
self.warning_count+=1
|
||||
|
||||
wiz_edi_import('edi.import')
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
import esale
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"name" : "EZ Publish eCommerce Interface",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"category" : "Interfaces/CMS & eCommerce",
|
||||
"website" : "http://tinyerp.com/demo02_6.html",
|
||||
"description": "Module to interface with the EZ Publish ecommerce system.",
|
||||
"depends" : ["product", "stock", "sale"],
|
||||
"init_xml" : [],
|
||||
"demo_xml" : ["esale_demo.xml"],
|
||||
"update_xml" : ["esale_view.xml"],
|
||||
"active": False,
|
||||
"installable": False
|
||||
}
|
|
@ -1,251 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: sale.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# 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 netsvc
|
||||
from osv import fields,osv,orm
|
||||
import ir
|
||||
|
||||
import time
|
||||
from mx import DateTime
|
||||
|
||||
class esale_web(osv.osv):
|
||||
_name = "esale.web"
|
||||
_description = "eCommerce Website"
|
||||
_columns = {
|
||||
'name': fields.char('eShop Name',size=64, required=True),
|
||||
'shop_id': fields.many2one('sale.shop', 'Sale Shop', required=True),
|
||||
'partner_anonymous_id': fields.many2one('res.partner', 'Anonymous', required=True),
|
||||
'active': fields.boolean('Active'),
|
||||
'product_all': fields.boolean('All product'),
|
||||
'product_ids': fields.many2many('product.product', 'esale_web_product_rel', 'web_id', 'product_id', 'Web Products')
|
||||
}
|
||||
_defaults = {
|
||||
'product_all': lambda *a: 1,
|
||||
'active': lambda *a: 1
|
||||
}
|
||||
#
|
||||
# Compute the stock for one product depending on the POS
|
||||
#
|
||||
def stock_get(self, cr, uid, shop_id, product_id):
|
||||
res = self.pool.get('product.product').read(cr, uid, [product_id], ['qty_available'], {'shop': shop_id})[0]['qty_available']
|
||||
return res
|
||||
|
||||
#
|
||||
# Compute the price for one product
|
||||
#
|
||||
def price_get(self, cr, uid, product_id, product_qty, partner_id):
|
||||
pricelist = self.pool.get('res.partner').browse(cr, uid, partner_id).property_product_pricelist.id
|
||||
price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], product_id, product_qty)[pricelist]
|
||||
return price
|
||||
|
||||
#
|
||||
# PRE:
|
||||
# order = {
|
||||
# 'partner_id': 1,
|
||||
# 'partner_name:'',
|
||||
# 'date':'20051010',
|
||||
# 'user_id':1,
|
||||
# 'products':[
|
||||
# {'product_id':1,
|
||||
# 'product_name':'',
|
||||
# 'price':19.9,
|
||||
# 'product_qty': 1}
|
||||
# ]
|
||||
#
|
||||
# POST:
|
||||
# order.extend({'price_subtotal': 0.0,
|
||||
# 'price_tax': 0.0,
|
||||
# 'price_total': 0.0,
|
||||
# 'products': [
|
||||
# {'product_id':1,
|
||||
# 'product_name':'',
|
||||
# 'price':19.9,
|
||||
# 'product_qty': 1,
|
||||
# 'qty_available': 1,
|
||||
# 'date_available': '20051010'}
|
||||
# ]})
|
||||
#
|
||||
def compute(self, cr, uid, ids, order, context={}):
|
||||
pricelist = self.pool.get('res.partner').browse(cr, uid, order['partner_id']).property_product_pricelist.id
|
||||
subtotal = 0
|
||||
taxes = 0
|
||||
for product in order['products']:
|
||||
product_id = int(product['product_id'])
|
||||
price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], product_id, int(product['product_qty']))[pricelist]
|
||||
product['price'] = price
|
||||
|
||||
prod_info = self.pool.get('product.product').read(cr, uid, [product_id], ['sale_delay', 'qty_available', 'code', 'name'])[0]
|
||||
dt = (DateTime.now() + DateTime.RelativeDateTime(days=prod_info['sale_delay'] or 0.0)).strftime('%Y-%m-%d')
|
||||
product['date_available'] = dt
|
||||
product['qty_available'] = prod_info['qty_available']
|
||||
product['code'] = prod_info['code']
|
||||
product['name'] = prod_info['name']
|
||||
product['subtotal'] = price * int(product['product_qty'])
|
||||
subtotal += (price * int(product['product_qty']))
|
||||
taxes += 0
|
||||
order['price_subtotal'] = subtotal
|
||||
order['price_tax'] = taxes
|
||||
order['price_total'] = taxes + subtotal
|
||||
return order
|
||||
esale_web()
|
||||
|
||||
#
|
||||
# Not yet Used !
|
||||
# For futur development, used to stock web user preferences
|
||||
#
|
||||
class esale_user(osv.osv):
|
||||
_name = "esale.user"
|
||||
_description = "eCommerce User"
|
||||
_columns = {
|
||||
'name': fields.char('User Name',size=64, required=True),
|
||||
'partner_id':fields.many2one('res.partner','Partner',required=True),
|
||||
'picking_policy': fields.selection([
|
||||
('direct','Direct Delivery'),
|
||||
('one','All at once')
|
||||
], 'Packing Policy', required=True ),
|
||||
'order_policy': fields.selection([
|
||||
('prepaid','Pay before delivery'),
|
||||
('manual','Shipping & Manual Invoice'),
|
||||
('postpaid','Invoice after delivery'),
|
||||
], 'Shipping Policy', required=True),
|
||||
'web_ref':fields.char('Web Reference', size=16, required=True),
|
||||
'web_id': fields.many2one('esale.web', 'Web Shop', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'order_policy': lambda *a: 'prepaid',
|
||||
'picking_policy': lambda *a: 'one'
|
||||
}
|
||||
esale_user()
|
||||
|
||||
class esale_order(osv.osv):
|
||||
_name='esale.order'
|
||||
_columns = {
|
||||
'name': fields.char('Order Description',size=64, required=True),
|
||||
'state': fields.selection([
|
||||
('draft','Draft'),
|
||||
('done','Done'),
|
||||
('cancel','Cancel')
|
||||
], 'Order State'),
|
||||
'date_order':fields.date('Date Ordered', required=True),
|
||||
'partner_id':fields.many2one('res.partner', 'Partner', required=True),
|
||||
'web_id':fields.many2one('esale.web', 'Web Shop', required=True),
|
||||
'web_ref':fields.integer('Web Ref'),
|
||||
'order_lines': fields.one2many('esale.order.line', 'order_id', 'Order Lines'),
|
||||
'order_id': fields.many2one('sale.order', 'Sale Order'),
|
||||
'note': fields.text('Notes'),
|
||||
}
|
||||
_defaults = {
|
||||
'date_order': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'state': lambda *a: 'draft',
|
||||
}
|
||||
|
||||
def order_create(self, cr, uid, ids, context={}):
|
||||
for order in self.browse(cr, uid, ids, context):
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [order.partner_id.id], ['delivery','invoice','contact'])
|
||||
pricelist_id=order.partner_id.property_product_pricelist.id
|
||||
order_lines = []
|
||||
for line in order.order_lines:
|
||||
order_lines.append( (0,0,{
|
||||
'name': line.name,
|
||||
'product_qty': line.product_qty,
|
||||
'date_planned': line.date_planned,
|
||||
'product_id': line.product_id.id,
|
||||
'product_uom': line.product_uom.id,
|
||||
'price_unit': line.price_unit,
|
||||
'type': line.product_id.procure_method
|
||||
}) )
|
||||
order_id = self.pool.get('sale.order').create(cr, uid, {
|
||||
'name': order.name,
|
||||
'shop_id': order.web_id.shop_id.id,
|
||||
'origin': 'WEB:'+str(order.id),
|
||||
'date_order': order.date_order,
|
||||
'user_id': uid,
|
||||
'partner_id': order.partner_id.id,
|
||||
'partner_invoice_id':addr['invoice'],
|
||||
'partner_order_id':addr['contact'],
|
||||
'partner_shipping_id':addr['delivery'],
|
||||
'pricelist_id': pricelist_id,
|
||||
'order_line': order_lines
|
||||
})
|
||||
self.write(cr, uid, [order.id], {'state':'done', 'order_id': order_id})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'sale.order', order_id, 'order_confirm', cr)
|
||||
return True
|
||||
|
||||
def order_cancel(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'cancel'})
|
||||
return True
|
||||
|
||||
def order_upload(self, cr, uid, web_id, orders):
|
||||
for order in orders:
|
||||
lines = []
|
||||
for prod in order['order_lines']:
|
||||
prod['product_uom'] = self.pool.get('product.product').browse(cr, uid, [prod['product_id']])[0].uom_id.id
|
||||
lines.append( (0,0, prod) )
|
||||
self.create(cr, uid, {
|
||||
'name': str(order['ref'])+': '+order['partner_name'],
|
||||
'partner_id': int(order['partner_id']),
|
||||
'web_id': int(web_id),
|
||||
'web_ref': int(order['ref']),
|
||||
'note': order['notes'],
|
||||
'order_lines': lines
|
||||
})
|
||||
return True
|
||||
|
||||
def state_get(self, cr, uid, refs):
|
||||
result = {}
|
||||
for r in refs:
|
||||
result[str(r)] = False
|
||||
ids = self.search(cr, uid, [('web_ref','in',map(int,refs))])
|
||||
for order in self.browse(cr, uid, ids):
|
||||
if order.order_id:
|
||||
result[str(order.web_ref)] = order.order_id.state
|
||||
else:
|
||||
result[str(order.web_ref)] = 'draft'
|
||||
return result
|
||||
esale_order()
|
||||
|
||||
class esale_order_line(osv.osv):
|
||||
_name = 'esale.order.line'
|
||||
_description = 'eSale Order line'
|
||||
_columns = {
|
||||
'name': fields.char('Order Line', size=64, required=True),
|
||||
'order_id': fields.many2one('esale.order', 'eOrder Ref'),
|
||||
'product_qty': fields.float('Quantity', digits=(16,2), required=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok','=',True)], change_default=True),
|
||||
'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True),
|
||||
'price_unit': fields.float('Unit Price', required=True),
|
||||
'date_planned': fields.date('Scheduled date', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'date_planned': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
esale_order_line()
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="vtree">
|
||||
<field name="name">esale.web.tree</field>
|
||||
<field name="model">esale.web</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSale Web Shop">
|
||||
<field name="name" select="1"/>
|
||||
<field name="partner_anonymous_id"/>
|
||||
<field name="shop_id" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data noupdate="1">
|
||||
<record model="esale.web" id="esale_web_shop1">
|
||||
<field name="name">eCommerce Shop</field>
|
||||
<field name="shop_id" model="sale.shop" search="[]"/>
|
||||
<field name="partner_anonymous_id" model="res.partner" search="[]"/>
|
||||
</record>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,167 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="vtree">
|
||||
<field name="name">esale.web.tree</field>
|
||||
<field name="model">esale.web</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSale Web Shop">
|
||||
<field name="name" select="1"/>
|
||||
<field name="partner_anonymous_id"/>
|
||||
<field name="shop_id" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_web_form">
|
||||
<field name="name">esale.web.form</field>
|
||||
<field name="model">esale.web</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSale Web Shop">
|
||||
<field name="name" select="1"/>
|
||||
<field name="active" select="1"/>
|
||||
<field name="shop_id" select="1"/>
|
||||
<field name="product_all"/>
|
||||
<field name="partner_anonymous_id" colspan="4"/>
|
||||
<field name="product_ids" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_shop_tree">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale.shop</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem name="Esales/Configuration/Ecommerce Website" id="menu_action_shop_tree" action="action_shop_tree" groups="admin"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_order_tree">
|
||||
<field name="name">esale.order.tree</field>
|
||||
<field name="model">esale.order</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sales Orders">
|
||||
<field name="name"/>
|
||||
<field name="date_order"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_order_form">
|
||||
<field name="name">esale.order.form</field>
|
||||
<field name="model">esale.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSale Order">
|
||||
<notebook>
|
||||
<page string="Order Line">
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<field name="partner_id" select="1"/>
|
||||
<field name="date_order" select="1"/>
|
||||
<field name="web_id" select="1"/>
|
||||
<field name="web_ref" select="1"/>
|
||||
<field name="order_lines" widget="one2many_list" colspan="4" nolabel="1"/>
|
||||
<separator string="States" colspan="4"/>
|
||||
<field name="state"/>
|
||||
<button type="object" name="order_create" states="draft" string="Create Order"/>
|
||||
<button type="object" name="order_cancel" states="draft" string="Cancel Order"/>
|
||||
</page>
|
||||
<page string="Others data">
|
||||
<field name="order_id" colspan="4"/>
|
||||
<field name="note" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_order_form">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_order_form"/>
|
||||
</record>
|
||||
<menuitem name="Esales/Esales Order" id="menu_action_order_form" action="action_order_form" groups="admin"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_order_tree">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','draft')]</field>
|
||||
</record>
|
||||
<menuitem name="Esales/Esales Order/Draft Esales Order" id="menu_action_order_tree" action="action_order_tree" groups="admin"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_order_line_form">
|
||||
<field name="name">esale.order.line.form</field>
|
||||
<field name="model">esale.order.line</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSales Order Line">
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="product_id" colspan="4"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom"/>
|
||||
|
||||
<field name="price_unit"/>
|
||||
<field name="date_planned"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_order_line_tree">
|
||||
<field name="name">esale.order.line.tree</field>
|
||||
<field name="model">esale.order.line</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSales Order Line">
|
||||
<field name="name"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom"/>
|
||||
<field name="price_unit"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_user_tree">
|
||||
<field name="name">esale.user.tree</field>
|
||||
<field name="model">esale.user</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSale user">
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="web_id"/>
|
||||
<field name="web_ref"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_user_form">
|
||||
<field name="name">esale.user.form</field>
|
||||
<field name="model">esale.user</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSale user">
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<field name="partner_id" select="1" colspan="4"/>
|
||||
<field name="web_id"/>
|
||||
<field name="web_ref"/>
|
||||
<field name="picking_policy"/>
|
||||
<field name="order_policy"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_user_form">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale.user</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_user_form"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name" : "eSale Interface - Joomla",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"category" : "Interfaces/CMS & eCommerce",
|
||||
"website" : "http://tinyerp.com",
|
||||
"depends" : ["product", "stock", "sale", "account", "account_tax_include",],
|
||||
"description": """Joomla (Virtuemart) eCommerce interface synchronisation.
|
||||
Users can order on the website, orders are automatically imported in Tiny
|
||||
ERP.
|
||||
|
||||
You can export products, stock level and create links between
|
||||
categories of products, taxes and languages.
|
||||
|
||||
If you product has an image attched, it send the image to the Joomla website.""",
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ['esale_joomla_wizard.xml', "esale_joomla_view.xml"],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,327 +0,0 @@
|
|||
<?php
|
||||
|
||||
define( '_VALID_MOS', 1);
|
||||
|
||||
include("xmlrpc.inc");
|
||||
include("xmlrpcs.inc");
|
||||
|
||||
require_once( 'configuration.php' );
|
||||
require_once( 'includes/joomla.php' );
|
||||
require_once( 'administrator/components/com_virtuemart/virtuemart.cfg.php' );
|
||||
|
||||
$con = mysql_pconnect($mosConfig_host, $mosConfig_user,$mosConfig_password );
|
||||
mysql_select_db($mosConfig_db);
|
||||
|
||||
function get_taxes() {
|
||||
global $mosConfig_dbprefix;
|
||||
$taxes=array();
|
||||
|
||||
$result=mysql_query("select tax_rate_id, tax_rate*100 from ".$mosConfig_dbprefix."vm_tax_rate;");
|
||||
if ($result) while ($row=mysql_fetch_row($result)) {
|
||||
$taxes[]=new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval("Tax ".$row[1]."%", "string")), "array");
|
||||
}
|
||||
return new xmlrpcresp( new xmlrpcval($taxes, "array"));
|
||||
}
|
||||
|
||||
function get_languages() {
|
||||
$languages=array();
|
||||
|
||||
$languages[]=new xmlrpcval(array(new xmlrpcval(1, "int"), new xmlrpcval("Unique", "string")), "array");
|
||||
return new xmlrpcresp( new xmlrpcval($languages, "array"));
|
||||
}
|
||||
|
||||
function get_categories() {
|
||||
global $mosConfig_dbprefix;
|
||||
$categories=array();
|
||||
|
||||
$result=mysql_query("select category_id, category_name from ".$mosConfig_dbprefix."vm_category;");
|
||||
if ($result) while ($row=mysql_fetch_row($result)) {
|
||||
$categories[]=new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval(parent_category($row[0],$row[1]), "string")), "array");
|
||||
}
|
||||
return new xmlrpcresp( new xmlrpcval($categories, "array"));
|
||||
}
|
||||
|
||||
function parent_category($id, $name) {
|
||||
global $mosConfig_dbprefix;
|
||||
$result=mysql_query("select category_parent_id from ".$mosConfig_dbprefix."vm_category_xref where category_child_id=".$id.";");
|
||||
if ($result && $row=mysql_fetch_row($result)) {
|
||||
if ($row[0]==0) {
|
||||
return $name;
|
||||
} else {
|
||||
$resultb=mysql_query("select category_name from ".$mosConfig_dbprefix."vm_category where category_id=".$row[0].";");
|
||||
if ($resultb && $rowb=mysql_fetch_row($resultb)) {
|
||||
$name=parent_category($row[0], $rowb[0] . " \\ ". $name);
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
function set_product_stock($tiny_product) {
|
||||
global $mosConfig_dbprefix;
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_in_stock=".$tiny_product['quantity']." where
|
||||
product_id=".$tiny_product['esale_joomla_id'].";");
|
||||
//mysql_query("update products set products_status=".(($tiny_product['quantity']>0)?1:0)." where
|
||||
//products_id=".$tiny_product['esale_joomla_id'].";");
|
||||
return new xmlrpcresp(new xmlrpcval(1,"int"));
|
||||
}
|
||||
|
||||
|
||||
function set_product_category($category_id, $product_ids) {
|
||||
|
||||
global $mosConfig_dbprefix;
|
||||
|
||||
foreach($product_ids as $key => $value){
|
||||
$result = mysql_query("select count(*) from ".$mosConfig_dbprefix."vm_product_category_xref where category_id=".$category_id." and product_id=".$value.";");
|
||||
$row = mysql_fetch_row($result);
|
||||
if (! $row[0] ){
|
||||
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_category_xref values (".$category_id.", ".$value.", NULL);");
|
||||
}
|
||||
}
|
||||
return new xmlrpcresp(new xmlrpcval(1,"int"));
|
||||
|
||||
}
|
||||
|
||||
function unpublish_product($product_ids){
|
||||
global $mosConfig_dbprefix;
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_publish='N' where product_id in (".implode(",",$product_ids).");");
|
||||
return new xmlrpcresp(new xmlrpcval(1,"int"));
|
||||
}
|
||||
|
||||
function debug($s) {
|
||||
$fp = fopen("/tmp/debug.xmlrpc.txt","a");
|
||||
fwrite($fp, $s."\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
|
||||
function set_product($tiny_product){
|
||||
global $mosConfig_dbprefix;
|
||||
$prod = Array(
|
||||
'vendor_id'=>0
|
||||
);
|
||||
|
||||
$result=mysql_query("select vendor_id, vendor_currency from ".$mosConfig_dbprefix."vm_vendor;");
|
||||
if ($result && $row=mysql_fetch_row($result)) {
|
||||
$prod['vendor_id']=$row[0];
|
||||
$prod['vendor_currency']=$row[1];
|
||||
}
|
||||
$result=mysql_query("select shopper_group_id from ".$mosConfig_dbprefix."vm_shopper_group where vendor_id=".$prod['vendor_id']." and shopper_group_name='-default-';");
|
||||
if ($result && $row=mysql_fetch_row($result))
|
||||
$prod['shopper_group']=$row[0];
|
||||
if ( $tiny_product['esale_joomla_id']) {
|
||||
$result = mysql_query("select count(*) from ".$mosConfig_dbprefix."vm_product where product_id=". $tiny_product['esale_joomla_id']);
|
||||
$row = mysql_fetch_row($result);
|
||||
if (! $row[0] )
|
||||
$tiny_product['esale_joomla_id'] = 0;
|
||||
}
|
||||
|
||||
if (! $tiny_product['esale_joomla_id']) {
|
||||
mysql_query("insert into ".$mosConfig_dbprefix."vm_product () values ()");
|
||||
$osc_id=mysql_insert_id();
|
||||
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_price (product_id, product_price, product_currency, product_price_vdate, product_price_edate, shopper_group_id) values (".$osc_id.", ".$tiny_product['price'].", '".$prod['vendor_currency']."', 0, 0, ".$prod['shopper_group'].");");
|
||||
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_category_xref (product_id, category_id) values (".$osc_id.", ".$tiny_product['category_id'].");");
|
||||
} else {
|
||||
$osc_id=$tiny_product['esale_joomla_id'];
|
||||
}
|
||||
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product set ".
|
||||
"product_in_stock=".$tiny_product['quantity'].",".
|
||||
"product_weight=".$tiny_product['weight'].",".
|
||||
"product_tax_id=".$tiny_product['tax_class_id'].",".
|
||||
"product_sku='".mysql_escape_string($tiny_product['model'])."',".
|
||||
"product_name='".mysql_escape_string($tiny_product['name'])."',".
|
||||
"vendor_id='".$prod['vendor_id']."',".
|
||||
"product_desc='".mysql_escape_string($tiny_product['description'])."', ".
|
||||
"product_publish='Y',".
|
||||
"product_s_desc='".mysql_escape_string(substr($tiny_product['description'],0,200))."' ".
|
||||
"where product_id=".$osc_id.";");
|
||||
|
||||
// Replace or
|
||||
// Delete old values
|
||||
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product_price set product_price='".$tiny_product['price']."' where product_id=".$osc_id.";");
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product_category set category_id='".$tiny_product['category_id']."' where product_id=".$osc_id.";");
|
||||
|
||||
if ($tiny_product['haspic']==1) {
|
||||
$filename=tempnam('components/com_virtuemart/shop_image/product/', 'tiny_');
|
||||
$extension=strrchr($tiny_product['fname'],'.');
|
||||
$filename.=$extension;
|
||||
//file_put_contents($filename, base64_decode($tiny_product['picture']));
|
||||
$hd=fopen($filename, "w");
|
||||
fwrite($hd, base64_decode($tiny_product['picture']));
|
||||
fclose($hd);
|
||||
$short=strrchr($filename,'/');
|
||||
$short=substr($short, 1, strlen($short));
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_full_image='".$short."' where product_id=".$osc_id.";");
|
||||
$newxsize = PSHOP_IMG_WIDTH;
|
||||
if (!$newxsize) {
|
||||
$newxsize=90;
|
||||
}
|
||||
$newysize = PSHOP_IMG_HEIGHT;
|
||||
if (!$newysize) {
|
||||
$newysize=60;
|
||||
}
|
||||
$extension=strtolower($extension);
|
||||
if (in_array($extension, array('.jpeg', '.jpe', '.jpg', '.gif', '.png'))) {
|
||||
if (in_array($extension, array('.jpeg', '.jpe', '.jpg'))) {
|
||||
$extension='.jpeg';
|
||||
}
|
||||
$thumb=tempnam('components/com_virtuemart/shop_image/product/', 'tiny_').$extension;
|
||||
$load='imagecreatefrom'.substr($extension,1,strlen($extension)-1);
|
||||
$save='image'.substr($extension,1,strlen($extension)-1);
|
||||
$tmp_img=$load($filename);
|
||||
$imgsize = getimagesize($filename);
|
||||
if ($imgsize[0] > $newxsize || $imgsize[1] > $newysize) {
|
||||
if ($imgsize[0]*$newysize > $imgsize[1]*$newxsize) {
|
||||
$ratio=$imgsize[0]/$newxsize;
|
||||
} else {
|
||||
$ratio=$imgsize[1]/$newysize;
|
||||
}
|
||||
} else {
|
||||
$ratio=1;
|
||||
}
|
||||
$tn=imagecreatetruecolor (floor($imgsize[0]/$ratio),floor($imgsize[1]/$ratio));
|
||||
imagecopyresized($tn,$tmp_img,0,0,0,0,floor($imgsize[0]/$ratio),floor($imgsize[1]/$ratio),$imgsize[0],$imgsize[1]);
|
||||
$short=strrchr($thumb,'/');
|
||||
$short=substr($short,1,strlen($short));
|
||||
$save($tn, $thumb);
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_thumb_image='".$short."' where product_id=".$osc_id.";");
|
||||
}
|
||||
}
|
||||
return new xmlrpcresp(new xmlrpcval($osc_id, "int"));
|
||||
}
|
||||
|
||||
function get_saleorders($last_so) {
|
||||
global $mosConfig_dbprefix;
|
||||
$saleorders=array();
|
||||
|
||||
$result=mysql_query(
|
||||
"SELECT
|
||||
o.`order_id`, c.`last_name`, c.`address_1`, c.`city`, c.`zip`, c.`state`,
|
||||
c.`country`, c.`phone_1`, c.`user_email`, d.`last_name` , d.`address_1` ,
|
||||
d.`city`, d.`zip`, d.`state`, d.`country`, o.`cdate`,
|
||||
c.title, c.first_name, d.title, d.first_name,
|
||||
d.user_id, c.user_id, o.customer_note
|
||||
FROM ".
|
||||
$mosConfig_dbprefix."vm_orders as o,".
|
||||
$mosConfig_dbprefix."vm_user_info as c, ".
|
||||
$mosConfig_dbprefix."vm_user_info as d
|
||||
where
|
||||
o.order_id>".$last_so." and
|
||||
o.user_id=c.user_id and
|
||||
(c.address_type_name is NULL or c.address_type_name='-default-') and
|
||||
o.user_info_id=d.user_info_id;
|
||||
");
|
||||
|
||||
if ($result) while ($row=mysql_fetch_row($result)) {
|
||||
$orderlines=array();
|
||||
$resultb=mysql_query("select product_id, product_quantity, product_item_price from ".$mosConfig_dbprefix."vm_order_item where order_id=".$row[0].";");
|
||||
if ($resultb) while ($rowb=mysql_fetch_row($resultb)) {
|
||||
$orderlines[]=new xmlrpcval( array(
|
||||
"product_id" => new xmlrpcval($rowb[0], "int"),
|
||||
"product_qty" => new xmlrpcval($rowb[1], "int"),
|
||||
"price" => new xmlrpcval($rowb[2], "int")
|
||||
), "struct");
|
||||
}
|
||||
$saleorders[] = new xmlrpcval( array(
|
||||
"id" => new xmlrpcval( $row[0], "int"),
|
||||
"note" => new xmlrpcval( $row[22], "string"),
|
||||
"lines" => new xmlrpcval( $orderlines, "array"),
|
||||
"address" => new xmlrpcval( array(
|
||||
"name" => new xmlrpcval($row[16]." ".$row[1]." ".$row[17], "string"),
|
||||
"address" => new xmlrpcval($row[2], "string"),
|
||||
"city" => new xmlrpcval($row[3], "string"),
|
||||
"zip" => new xmlrpcval($row[4], "string"),
|
||||
"state" => new xmlrpcval($row[5], "string"),
|
||||
"country" => new xmlrpcval($row[6], "string"),
|
||||
"phone" => new xmlrpcval($row[7], "string"),
|
||||
"email" => new xmlrpcval($row[8], "string"),
|
||||
"esale_id" => new xmlrpcval($row[20], "string")
|
||||
), "struct"),
|
||||
"delivery" => new xmlrpcval( array(
|
||||
"name" => new xmlrpcval($row[18]." ".$row[9]." ".$row[19], "string"),
|
||||
"address" => new xmlrpcval($row[10], "string"),
|
||||
"city" => new xmlrpcval($row[11], "string"),
|
||||
"zip" => new xmlrpcval($row[12], "string"),
|
||||
"state" => new xmlrpcval($row[13], "string"),
|
||||
"country" => new xmlrpcval($row[14], "string"),
|
||||
"email" => new xmlrpcval($row[8], "string"),
|
||||
"esale_id" => new xmlrpcval($row[21], "string")
|
||||
), "struct"),
|
||||
"billing" =>new xmlrpcval( array(
|
||||
"name" => new xmlrpcval($row[16]." ".$row[1]." ".$row[17], "string"),
|
||||
"address" => new xmlrpcval($row[2], "string"),
|
||||
"city" => new xmlrpcval($row[3], "string"),
|
||||
"zip" => new xmlrpcval($row[4], "string"),
|
||||
"state" => new xmlrpcval($row[5], "string"),
|
||||
"country" => new xmlrpcval($row[6], "string"),
|
||||
"email" => new xmlrpcval($row[8], "string"),
|
||||
"esale_id" => new xmlrpcval($row[20], "string")
|
||||
), "struct"),
|
||||
"date" => new xmlrpcval( date('YmdHis',$row[15]), "date")
|
||||
), "struct");
|
||||
}
|
||||
return new xmlrpcresp(new xmlrpcval($saleorders, "array"));
|
||||
}
|
||||
|
||||
function process_order($order_id) {
|
||||
global $mosConfig_dbprefix;
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_orders set order_status='C' where order_id=".$order_id.";");
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_order_item set oerder_status='C' where order_id=".$order_id.";");
|
||||
return new xmlrpcresp(new xmlrpcval(0, "int"));
|
||||
}
|
||||
|
||||
function close_order($order_id) {
|
||||
global $mosConfig_dbprefix;
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_orders set order_status='S' where order_id=".$order_id.";");
|
||||
mysql_query("update ".$mosConfig_dbprefix."vm_order_item set oerder_status='S' where order_id=".$order_id.";");
|
||||
return new xmlrpcresp(new xmlrpcval(0, "int"));
|
||||
}
|
||||
|
||||
$server = new xmlrpc_server( array(
|
||||
"get_taxes" => array(
|
||||
"function" => "get_taxes",
|
||||
"signature" => array(array($xmlrpcArray))
|
||||
),
|
||||
"get_languages" => array(
|
||||
"function" => "get_languages",
|
||||
"signature" => array(array($xmlrpcArray))
|
||||
),
|
||||
"get_categories" => array(
|
||||
"function" => "get_categories",
|
||||
"signature" => array(array($xmlrpcArray))
|
||||
),
|
||||
"get_saleorders" => array(
|
||||
"function" => "get_saleorders",
|
||||
"signature" => array(array($xmlrpcArray, $xmlrpcInt))
|
||||
),
|
||||
"set_product_category" => array(
|
||||
"function" => "set_product_category",
|
||||
"signature" => array(array($xmlrpcInt, $xmlrpcInt, $xmlrpcArray))
|
||||
),
|
||||
"unpublish_product" => array(
|
||||
"function" => "unpublish_product",
|
||||
"signature" => array(array($xmlrpcInt, $xmlrpcArray))
|
||||
),
|
||||
"set_product" => array(
|
||||
"function" => "set_product",
|
||||
"signature" => array(array($xmlrpcInt, $xmlrpcStruct))
|
||||
),
|
||||
"set_product_stock" => array(
|
||||
"function" => "set_product_stock",
|
||||
"signature" => array(array($xmlrpcInt, $xmlrpcStruct))
|
||||
),
|
||||
"process_order" => array(
|
||||
"function" => "process_order",
|
||||
"signature" => array(array($xmlrpcInt, $xmlrpcInt))
|
||||
),
|
||||
"close_order" => array(
|
||||
"function" => "close_order",
|
||||
"signature" => array(array($xmlrpcInt, $xmlrpcInt))
|
||||
)
|
||||
), false);
|
||||
$server->functions_parameters_type= 'phpvals';
|
||||
$server->service();
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,293 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: sale.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# 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 netsvc
|
||||
from osv import fields,osv,orm
|
||||
import ir
|
||||
|
||||
import time
|
||||
import xmlrpclib
|
||||
|
||||
from mx import DateTime
|
||||
|
||||
class esale_joomla_web(osv.osv):
|
||||
_name = "esale_joomla.web"
|
||||
_description = "eCommerce Website"
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name',size=64, required=True),
|
||||
'url': fields.char('URL', size=64, required=True),
|
||||
'shop_id': fields.many2one('sale.shop', 'Sale Shop', required=True),
|
||||
'active': fields.boolean('Active'),
|
||||
'product_ids': fields.one2many('esale_joomla.product', 'web_id', string='Products'),
|
||||
'tax_ids': fields.one2many('esale_joomla.tax', 'web_id', string='Taxes'),
|
||||
'taxes_included_ids': fields.many2many('account.tax', 'esale_joomla_web_taxes_included_rel', 'esale_joomla_web_id', 'tax_id', 'Taxes included', domain=[('parent_id', '=', False)]),
|
||||
'category_ids': fields.one2many('esale_joomla.category', 'web_id', string='Categories'),
|
||||
'language_id' : fields.many2one('res.lang', 'Language'),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: 1
|
||||
}
|
||||
def tax_import(self, cr, uid, ids, *args):
|
||||
for website in self.browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-synchro.php" % website.url)
|
||||
taxes = server.get_taxes()
|
||||
for tax in taxes:
|
||||
value={
|
||||
'web_id' : website.id,
|
||||
'esale_joomla_id' : tax[0],
|
||||
'name' : tax[1]
|
||||
}
|
||||
self.pool.get('esale_joomla.tax').create(cr, uid, value)
|
||||
return True
|
||||
|
||||
def lang_import(self, cr, uid, ids, *args):
|
||||
for website in self.browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-synchro.php" % website.url)
|
||||
languages = server.get_languages()
|
||||
for language in languages:
|
||||
value={
|
||||
'web_id': website.id,
|
||||
'esale_joomla_id': language[0],
|
||||
'name': language[1]
|
||||
}
|
||||
self.pool.get('esale_joomla.lang').create(cr, uid, value)
|
||||
return True
|
||||
|
||||
def category_import(self, cr, uid, ids, *args):
|
||||
for website in self.browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-synchro.php" % website.url)
|
||||
categories = server.get_categories()
|
||||
category_pool = self.pool.get('esale_joomla.category')
|
||||
for category in categories:
|
||||
value={
|
||||
'web_id': website.id,
|
||||
'esale_joomla_id': category[0],
|
||||
'name': category[1]
|
||||
}
|
||||
existing = category_pool.search(cr, uid, [('web_id','=',website.id), ('esale_joomla_id', '=', category[0])])
|
||||
if len(existing)>0:
|
||||
category_pool.write(cr, uid, existing, value)
|
||||
else:
|
||||
category_pool.create(cr, uid, value)
|
||||
return True
|
||||
esale_joomla_web()
|
||||
|
||||
class esale_joomla_tax(osv.osv):
|
||||
_name = "esale_joomla.tax"
|
||||
_description = "eSale Tax"
|
||||
_columns = {
|
||||
'name' : fields.char('Tax name', size=32, required=True),
|
||||
'esale_joomla_id' : fields.integer('eSale id'),
|
||||
'tax_id' : fields.many2one('account.tax', 'Tax'),
|
||||
'web_id' : fields.many2one('esale_joomla.web', 'Website')
|
||||
}
|
||||
esale_joomla_tax()
|
||||
|
||||
class esale_joomla_category(osv.osv):
|
||||
_name = "esale_joomla.category"
|
||||
_description = "eSale Category"
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'esale_joomla_id': fields.integer('Web ID', readonly=True, required=True),
|
||||
'web_id': fields.many2one('esale_joomla.web', 'Website'),
|
||||
'category_id': fields.many2one('product.category', 'Category'),
|
||||
'include_childs': fields.boolean('Include Childs', help="If checked, Tiny ERP will also export products from categories that are childs of this one."),
|
||||
}
|
||||
esale_joomla_category()
|
||||
|
||||
class esale_joomla_product(osv.osv):
|
||||
_name = "esale_joomla.product"
|
||||
_description = "eSale Product"
|
||||
_columns = {
|
||||
'web_id' : fields.many2one('esale_joomla.web', 'Web Ref'),
|
||||
'name' : fields.char('Name', size=64, required=True),
|
||||
'product_id' : fields.many2one('product.product', 'Product', required=True),
|
||||
'esale_joomla_id' : fields.integer('eSale product id'),
|
||||
'esale_joomla_tax_id' : fields.many2one('esale_joomla.tax', 'eSale tax'),
|
||||
}
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, web_id=False):
|
||||
value={}
|
||||
if (product_id):
|
||||
product=self.pool.get('product.product').browse(cr, uid, product_id)
|
||||
value['name']=product.name
|
||||
return {'value': value}
|
||||
esale_joomla_product()
|
||||
|
||||
class esale_joomla_language(osv.osv):
|
||||
_name = "esale_joomla.lang"
|
||||
_description = "eSale Language"
|
||||
_columns = {
|
||||
'name' : fields.char('Name', size=32, required=True),
|
||||
'esale_joomla_id' : fields.integer('Web ID', required=True),
|
||||
'language_id' : fields.many2one('res.lang', 'Language'),
|
||||
'web_id' : fields.many2one('esale_joomla.web', 'Website')
|
||||
}
|
||||
esale_joomla_language()
|
||||
|
||||
class esale_joomla_partner(osv.osv):
|
||||
_name='esale_joomla.partner'
|
||||
_description = 'eShop Partner'
|
||||
_columns = {
|
||||
'name': fields.char('Name',size=64, required=True),
|
||||
'esale_id': fields.char('eSale ID', size=64),
|
||||
'address': fields.char('Address',size=128),
|
||||
'city': fields.char('City',size=64),
|
||||
'zip': fields.char('Zip',size=64),
|
||||
'country': fields.char('Country',size=64),
|
||||
'email': fields.char('Mail',size=64),
|
||||
'state': fields.char('State',size=64),
|
||||
'address_id': fields.many2one('res.partner.address', 'Partner Address'),
|
||||
}
|
||||
def address_set(self, cr, uid, ids, context={}):
|
||||
for adr in self.browse(cr, uid, ids, context):
|
||||
if adr.address_id:
|
||||
continue
|
||||
country = self.pool.get('res.country').name_search(cr, uid, adr.country)
|
||||
state = self.pool.get('res.country.state').name_search(cr, uid, adr.state)
|
||||
create_id = self.pool.get('res.partner').create(cr, uid, {
|
||||
'name': adr.name,
|
||||
})
|
||||
create_id2 = self.pool.get('res.partner.address').create(cr, uid, {
|
||||
'street': adr.address,
|
||||
'partner_id': create_id,
|
||||
'zip': adr.zip,
|
||||
'city': adr.city,
|
||||
'email': adr.email,
|
||||
'country_id': country and country[0][0] or False,
|
||||
'state_id': state and state[0][0] or False,
|
||||
})
|
||||
self.write(cr, uid, [adr.id], {'address_id': create_id2} )
|
||||
return True
|
||||
esale_joomla_partner()
|
||||
|
||||
class esale_joomla_order(osv.osv):
|
||||
_name='esale_joomla.order'
|
||||
_columns = {
|
||||
'name': fields.char('Order Description',size=64, required=True),
|
||||
'state': fields.selection([
|
||||
('draft','Draft'),
|
||||
('done','Done'),
|
||||
('cancel','Cancel')
|
||||
], 'Order State'),
|
||||
'date_order':fields.date('Date Ordered', required=True),
|
||||
|
||||
'epartner_shipping_id':fields.many2one('esale_joomla.partner', 'Joomla Shipping Address', required=True),
|
||||
'epartner_invoice_id':fields.many2one('esale_joomla.partner', 'Joomla Invoice Address', required=True),
|
||||
|
||||
'partner_id':fields.many2one('res.partner', 'Contact Address'),
|
||||
'partner_shipping_id':fields.many2one('res.partner.address', 'Shipping Address'),
|
||||
'partner_invoice_id':fields.many2one('res.partner.address', 'Invoice Address'),
|
||||
|
||||
'web_id':fields.many2one('esale_joomla.web', 'Web Shop', required=True),
|
||||
'web_ref':fields.integer('Web Ref'),
|
||||
|
||||
'order_lines': fields.one2many('esale_joomla.order.line', 'order_id', 'Order Lines'),
|
||||
'order_id': fields.many2one('sale.order', 'Sale Order'),
|
||||
'note': fields.text('Notes'),
|
||||
}
|
||||
_defaults = {
|
||||
'date_order': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'state': lambda *a: 'draft',
|
||||
}
|
||||
|
||||
def order_create(self, cr, uid, ids, context={}):
|
||||
for order in self.browse(cr, uid, ids, context):
|
||||
if not (order.partner_id and order.partner_invoice_id and order.partner_shipping_id):
|
||||
raise osv.except_osv('No addresses !', 'You must assign addresses before creating the order.')
|
||||
pricelist_id=order.partner_id.property_product_pricelist.id
|
||||
order_lines = []
|
||||
for line in order.order_lines:
|
||||
val = {
|
||||
'name': line.name,
|
||||
'product_uom_qty': line.product_qty,
|
||||
'product_id': line.product_id.id,
|
||||
'product_uom': line.product_uom_id.id,
|
||||
'price_unit': line.price_unit,
|
||||
}
|
||||
val_new = self.pool.get('sale.order.line').product_id_change(cr, uid, None, pricelist_id, line.product_id.id, line.product_qty, line.product_uom_id.id, name=line.name)['value']
|
||||
del val_new['price_unit']
|
||||
del val_new['weight']
|
||||
val.update( val_new )
|
||||
val['tax_id'] = [(6,0,val['tax_id'])]
|
||||
order_lines.append( (0,0,val) )
|
||||
order_id = self.pool.get('sale.order').create(cr, uid, {
|
||||
'name': order.name,
|
||||
'shop_id': order.web_id.shop_id.id,
|
||||
'origin': 'WEB:'+str(order.web_ref),
|
||||
'user_id': uid,
|
||||
'note': order.note or '',
|
||||
'partner_id': order.partner_id.id,
|
||||
'partner_invoice_id':order.partner_invoice_id.id,
|
||||
'partner_order_id':order.partner_invoice_id.id,
|
||||
'partner_shipping_id':order.partner_shipping_id.id,
|
||||
'pricelist_id': pricelist_id,
|
||||
'order_line': order_lines
|
||||
})
|
||||
self.write(cr, uid, [order.id], {'state':'done', 'order_id': order_id})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'sale.order', order_id, 'order_confirm', cr)
|
||||
return True
|
||||
|
||||
def address_set(self, cr, uid, ids, *args):
|
||||
done = []
|
||||
for order in self.browse(cr, uid, ids):
|
||||
for a in [order.epartner_shipping_id.id,order.epartner_invoice_id.id]:
|
||||
if a not in done:
|
||||
done.append(a)
|
||||
self.pool.get('esale_joomla.partner').address_set(cr, uid, [a] )
|
||||
self.write(cr, uid, [order.id], {
|
||||
'partner_shipping_id': order.epartner_invoice_id.address_id.id,
|
||||
'partner_id': order.epartner_invoice_id.address_id.partner_id.id,
|
||||
'partner_invoice_id': order.epartner_shipping_id.address_id.id,
|
||||
})
|
||||
return True
|
||||
|
||||
def order_cancel(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'cancel'})
|
||||
return True
|
||||
esale_joomla_order()
|
||||
|
||||
class esale_joomla_order_line(osv.osv):
|
||||
_name = 'esale_joomla.order.line'
|
||||
_description = 'eSale Order line'
|
||||
_columns = {
|
||||
'name': fields.char('Order Line', size=64, required=True),
|
||||
'order_id': fields.many2one('esale_joomla.order', 'eOrder Ref'),
|
||||
'product_qty': fields.float('Quantity', digits=(16,2), required=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok','=',True)], change_default=True),
|
||||
'product_uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
|
||||
'price_unit': fields.float('Unit Price', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
}
|
||||
esale_joomla_order_line()
|
||||
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_esale_joomla_form">
|
||||
<field name="name">esale_joomla.web.form</field>
|
||||
<field name="model">esale_joomla.web</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSale Web Shop">
|
||||
<notebook>
|
||||
<page string="General Informations">
|
||||
<separator string="Web Shop Info" colspan="4"/>
|
||||
<field name="name" select="1" colspan="3"/>
|
||||
<field name="url" widget="url" required="1"/>
|
||||
<field name="active" select="1"/>
|
||||
<field name="shop_id" select="1" required="1"/>
|
||||
<field name="language_id" select="1" required="1"/>
|
||||
<separator string="Configuration Instructions" colspan="4"/>
|
||||
<label string="After having completed the above data, proceed to the taxes, languages and categories mapping. Go to the next tabs, import data form the website and complete the third column." align="0.0" colspan="4"/>
|
||||
</page>
|
||||
<page string="Taxes Mapping">
|
||||
<button type="object" string="Initial Import of Taxes" colspan="4" name="tax_import"/>
|
||||
<separator string="Taxes" colspan="4"/>
|
||||
<field colspan="4" name="tax_ids" nolabel="1">
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="esale_joomla_id" readonly="1"/>
|
||||
<field name="tax_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
<separator string="Taxes included" colspan="4"/>
|
||||
<field colspan="4" name="taxes_included_ids" nolabel="1"/>
|
||||
</page>
|
||||
<page string="Categories Mapping">
|
||||
<button type="object" string="Synchronise products categories" colspan="4" name="category_import"/>
|
||||
<field colspan="4" name="category_ids" nolabel="1">
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="esale_joomla_id" readonly="1"/>
|
||||
<field name="category_id"/>
|
||||
<field name="include_childs"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_esale_joomla_tree">
|
||||
<field name="name">esale_joomla.web.tree</field>
|
||||
<field name="model">esale_joomla.web</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSale Web Shop">
|
||||
<field name="name"/>
|
||||
<field name="url"/>
|
||||
<field name="active"/>
|
||||
<field name="shop_id"/>
|
||||
<field name="language_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_esale_joomla_form">
|
||||
<field name="res_model">esale_joomla.web</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_esale_joomla_tree"/>
|
||||
</record>
|
||||
<menuitem name="Sales Management/Esale/Definition/Web Shop" id="menu_action_esale_joomla_web" action="action_esale_joomla_form" groups="admin"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_esale_joomla_product_form">
|
||||
<field name="name">esale_joomla.product.form</field>
|
||||
<field name="model">esale_joomla.product</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSale product">
|
||||
<field name="name" select="1"/>
|
||||
<field name="esale_joomla_id" select="1"/>
|
||||
<field name="product_id" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_esale_joomla_product_tree">
|
||||
<field name="name">esale_joomla.product.tree</field>
|
||||
<field name="model">esale_joomla.product</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSale product">
|
||||
<field name="name" select="1"/>
|
||||
<field name="esale_joomla_id" select="1"/>
|
||||
<field name="product_id" select="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_esale_joomla_product_form">
|
||||
<field name="res_model">esale_joomla.product</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_esale_joomla_product_tree"/>
|
||||
</record>
|
||||
<menuitem name="Sales Management/Esale/Definition/Web Product" id="menu_action_esale_joomla_product" action="action_esale_joomla_product_form" groups="admin"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_order_tree">
|
||||
<field name="name">esale_joomla.order.tree</field>
|
||||
<field name="model">esale_joomla.order</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sales Orders">
|
||||
<field name="name"/>
|
||||
<field name="date_order"/>
|
||||
<field name="epartner_invoice_id"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_order_form">
|
||||
<field name="name">esale_joomla.order.form</field>
|
||||
<field name="model">esale_joomla.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSale Order">
|
||||
<notebook>
|
||||
<page string="Order Line">
|
||||
<field name="name" select="1"/>
|
||||
<field name="date_order" select="1"/>
|
||||
<field name="epartner_invoice_id" select="2"/>
|
||||
<field name="epartner_shipping_id" select="2"/>
|
||||
<field name="partner_invoice_id"/>
|
||||
<field name="partner_shipping_id"/>
|
||||
<field name="partner_id" select="1"/>
|
||||
<button string="Create Addresses" colspan="2" type="object" name="address_set"/>
|
||||
<field name="web_ref" select="2"/>
|
||||
<field name="web_id" select="2"/>
|
||||
<field name="order_lines" widget="one2many_list" colspan="4" nolabel="1"/>
|
||||
<separator string="States" colspan="4"/>
|
||||
<field name="state"/>
|
||||
<button type="object" name="order_create" states="draft" string="Create Order"/>
|
||||
<button type="object" name="order_cancel" states="draft" string="Cancel Order"/>
|
||||
</page>
|
||||
<page string="Others data">
|
||||
<field name="order_id" colspan="3"/>
|
||||
<field name="note" colspan="3"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_order_form">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale_joomla.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_order_tree"/>
|
||||
</record>
|
||||
<menuitem name="Sales Management/Esale/Esale Orders" id="menu_action_order_form" action="action_order_form" groups="admin"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_order_tree">
|
||||
<field name="name">Draft eSale Order</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale_joomla.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','draft')]</field>
|
||||
</record>
|
||||
<menuitem name="Sales Management/Esale/Esale Orders/Draft Esale Orders" id="menu_action_order_tree" action="action_order_tree" groups="admin"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_order_line_form">
|
||||
<field name="name">esale_joomla.order.line.form</field>
|
||||
<field name="model">esale_joomla.order.line</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="eSales Order Line">
|
||||
<field name="name" colspan="3"/>
|
||||
<field name="product_id" colspan="3"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom_id"/>
|
||||
<field name="price_unit"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_order_line_tree">
|
||||
<field name="name">esale_joomla.order.line.tree</field>
|
||||
<field name="model">esale_joomla.order.line</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="eSales Order Line">
|
||||
<field name="name"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom_id"/>
|
||||
<field name="price_unit"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<wizard
|
||||
string="Export products"
|
||||
model="esale_joomla.web"
|
||||
name="esale_joomla.products"
|
||||
menu="False"
|
||||
id="wizard_esale_joomla_products"/>
|
||||
|
||||
<menuitem
|
||||
name="Sales Management/Esale/Synchronisation/Export Products"
|
||||
action="wizard_esale_joomla_products"
|
||||
type="wizard"
|
||||
id="menu_esale_joomla_products"/>
|
||||
|
||||
<wizard
|
||||
string="Update stocks"
|
||||
model="esale_joomla.web"
|
||||
name="esale_joomla.stocks"
|
||||
menu="False"
|
||||
id="wizard_esale_joomla_stocks"/>
|
||||
<menuitem
|
||||
name="Sales Management/Esale/Synchronisation/Export Inventory Level"
|
||||
action="wizard_esale_joomla_stocks"
|
||||
type="wizard"
|
||||
id="menu_wizard_esale_joomla_stocks"/>
|
||||
|
||||
<wizard
|
||||
string="Import sale orders"
|
||||
model="esale_joomla.web"
|
||||
name="esale_joomla.saleorders"
|
||||
menu="False"
|
||||
id="wizard_esale_joomla_saleorders"/>
|
||||
<menuitem
|
||||
name="Sales Management/Esale/Synchronisation/Import Esales Orders"
|
||||
action="wizard_esale_joomla_saleorders"
|
||||
type="wizard"
|
||||
id="menu_esale_joomla_saleorders"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
import wizard_product_export
|
||||
import wizard_esale_import
|
||||
import wizard_product_stock
|
|
@ -1,105 +0,0 @@
|
|||
import netsvc
|
||||
import ir
|
||||
import time
|
||||
import os
|
||||
import netsvc
|
||||
import xmlrpclib
|
||||
import pooler
|
||||
|
||||
import wizard
|
||||
from osv import osv
|
||||
|
||||
_import_done_fields = {
|
||||
'num': {'string':'New Sales Orders', 'readonly':True, 'type':'integer'}
|
||||
}
|
||||
|
||||
_import_done_form = '''<?xml version="1.0"?>
|
||||
<form string="Saleorders import">
|
||||
<separator string="eSale Orders imported" colspan="4" />
|
||||
<field name="num"/>
|
||||
</form>'''
|
||||
|
||||
def _do_import(self, cr, uid, data, context):
|
||||
self.pool = pooler.get_pool(cr.dbname)
|
||||
ids = self.pool.get('esale_joomla.web').search(cr, uid, [])
|
||||
total = 0
|
||||
for website in self.pool.get('esale_joomla.web').browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-synchro.php" % website.url)
|
||||
|
||||
cr.execute("select max(web_ref) from esale_joomla_order where web_id=%d", (website.id,))
|
||||
max_web_id=cr.fetchone()[0]
|
||||
|
||||
saleorders = server.get_saleorders(max_web_id or 0)
|
||||
for so in saleorders:
|
||||
total += 1
|
||||
pids = self.pool.get('esale_joomla.partner').search(cr, uid, [('esale_id','=',so['delivery']['esale_id'])])
|
||||
if pids:
|
||||
adr_ship = pids[0]
|
||||
self.pool.get('esale_joomla.partner').write(cr, uid, pids, so['delivery'] )
|
||||
else:
|
||||
adr_ship = self.pool.get('esale_joomla.partner').create(cr, uid, so['delivery'] )
|
||||
|
||||
pids = self.pool.get('esale_joomla.partner').search(cr, uid, [('esale_id','=',so['billing']['esale_id'])])
|
||||
if pids:
|
||||
adr_bill = pids[0]
|
||||
self.pool.get('esale_joomla.partner').write(cr, uid, pids, so['billing'] )
|
||||
else:
|
||||
adr_bill = self.pool.get('esale_joomla.partner').create(cr, uid, so['billing'] )
|
||||
|
||||
order_id=self.pool.get('esale_joomla.order').create(cr, uid, {
|
||||
'web_id': website.id,
|
||||
'web_ref': so['id'],
|
||||
'name': so['id'],
|
||||
'date_order': so['date'] or time.strftime('%Y-%m-%d'),
|
||||
'note': so['note'] or '',
|
||||
'epartner_shipping_id': adr_ship,
|
||||
'epartner_invoice_id': adr_bill,
|
||||
})
|
||||
|
||||
for orderline in so['lines']:
|
||||
ids=self.pool.get('esale_joomla.product').search(cr, uid, [('esale_joomla_id', '=', orderline['product_id']), ('web_id', '=', website.id)])
|
||||
|
||||
if ids:
|
||||
osc_product_id=ids[0]
|
||||
osc_product=self.pool.get('esale_joomla.product').browse(cr, uid, osc_product_id)
|
||||
price=orderline['price']
|
||||
taxes_included=[]
|
||||
for taxe in osc_product.product_id.taxes_id:
|
||||
for t in website.taxes_included_ids:
|
||||
if t.id == taxe.id:
|
||||
taxes_included.append(taxe)
|
||||
for c in self.pool.get('account.tax').compute_inv(cr, uid, taxes_included, price, 1, product=osc_product.product_id):
|
||||
price-=c['amount']
|
||||
|
||||
a = {
|
||||
'product_id': osc_product.product_id.id,
|
||||
'product_qty': orderline['product_qty'],
|
||||
'name': osc_product.name,
|
||||
'order_id': order_id,
|
||||
'product_uom_id': osc_product.product_id.uom_id.id,
|
||||
'price_unit': price,
|
||||
}
|
||||
self.pool.get('esale_joomla.order.line').create(cr, uid, {
|
||||
'product_id': osc_product.product_id.id,
|
||||
'product_qty': orderline['product_qty'],
|
||||
'name': osc_product.name,
|
||||
'order_id': order_id,
|
||||
'product_uom_id': osc_product.product_id.uom_id.id,
|
||||
'price_unit': price,
|
||||
})
|
||||
cr.commit()
|
||||
return {'num':total}
|
||||
|
||||
class wiz_esale_joomla_import_sos(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_do_import],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': _import_done_form,
|
||||
'fields': _import_done_fields,
|
||||
'state': [('end', 'End')]
|
||||
}
|
||||
}
|
||||
}
|
||||
wiz_esale_joomla_import_sos('esale_joomla.saleorders');
|
|
@ -1,179 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# 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 ir
|
||||
import time
|
||||
import os
|
||||
import netsvc
|
||||
import xmlrpclib
|
||||
import netsvc
|
||||
import pooler
|
||||
import urllib
|
||||
import base64
|
||||
|
||||
import wizard
|
||||
from osv import osv
|
||||
|
||||
_export_done_form = '''<?xml version="1.0"?>
|
||||
<form string="Initial import">
|
||||
<separator string="Products exported" colspan="4" />
|
||||
<field name="prod_new"/>
|
||||
<newline/>
|
||||
<field name="prod_update"/>
|
||||
</form>'''
|
||||
|
||||
_export_done_fields = {
|
||||
'prod_new': {'string':'New products', 'type':'float', 'readonly': True},
|
||||
'prod_update': {'string':'Updated products', 'type':'float', 'readonly': True},
|
||||
}
|
||||
|
||||
def _product_id_to_joomla_id(cr,uid,pool,product,website):
|
||||
esale_joomla_id2 = pool.get('esale_joomla.product').search(cr, uid, [('web_id','=',website.id),('product_id','=',product.id)])
|
||||
esale_joomla_id = 0
|
||||
if esale_joomla_id2:
|
||||
esale_joomla_id = pool.get('esale_joomla.product').read(cr, uid, [esale_joomla_id2[0]],["esale_joomla_id"])[0]["esale_joomla_id"]
|
||||
return esale_joomla_id
|
||||
|
||||
def _do_export(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = pool.get('esale_joomla.web').search(cr, uid, [])
|
||||
prod_new = 0
|
||||
prod_update = 0
|
||||
for website in pool.get('esale_joomla.web').browse(cr, uid, ids):
|
||||
|
||||
pricelist = website.shop_id.pricelist_id.id
|
||||
if not pricelist:
|
||||
raise wizard.except_wizard('UserError', 'You must define a pricelist in your shop !')
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-synchro.php" % website.url)
|
||||
context['lang']=website.language_id.code
|
||||
categ_processed = []
|
||||
|
||||
## delete book if necessary :
|
||||
cr.execute("select jp.id, esale_joomla_id from esale_joomla_product jp inner join product_template pt on pt.id = jp.product_id where pt.categ_id not in (select category_id from esale_joomla_category) ")
|
||||
esale_ids= []
|
||||
joomla_ids= []
|
||||
for res in cr.fetchall():
|
||||
esale_ids.append(res[0])
|
||||
joomla_ids.append(res[1])
|
||||
if joomla_ids : server.unpublish_product(joomla_ids)
|
||||
pool.get('esale_joomla.product').unlink(cr,uid,esale_ids)
|
||||
|
||||
for categ in website.category_ids:
|
||||
if not categ.category_id: continue
|
||||
## for product already uploaded via another category we
|
||||
## just update the current category :
|
||||
if categ.category_id.id in categ_processed :
|
||||
prod_ids = pool.get('product.product').search(cr, uid, [('categ_id','in',cat_ids)])
|
||||
product_ids = []
|
||||
for product in pool.get('product.product').browse(cr, uid, prod_ids, context=context):
|
||||
product_ids.append( _product_id_to_joomla_id(cr,uid,pool,product,website))
|
||||
server.set_product_category(categ.esale_joomla_id ,product_ids)
|
||||
continue
|
||||
|
||||
cat_ids = [categ.category_id.id]
|
||||
if categ.include_childs:
|
||||
def _add_child(cat_ids, categ):
|
||||
for child in categ.child_id:
|
||||
if child.id not in cat_ids:
|
||||
cat_ids.append(child.id)
|
||||
_add_child(cat_ids, child)
|
||||
_add_child(cat_ids, categ.category_id)
|
||||
categ_processed.extend(cat_ids)
|
||||
|
||||
prod_ids = pool.get('product.product').search(cr, uid, [('categ_id','in',cat_ids)])
|
||||
for product in pool.get('product.product').browse(cr, uid, prod_ids, context=context):
|
||||
|
||||
esale_joomla_id= _product_id_to_joomla_id(cr,uid,pool,product,website)
|
||||
|
||||
price = pool.get('product.pricelist').price_get(cr, uid, [pricelist], product.id, 1, 'list')[pricelist]
|
||||
|
||||
taxes_included=[]
|
||||
taxes_name=[]
|
||||
for taxe in product.taxes_id:
|
||||
for t in website.taxes_included_ids:
|
||||
if t.id == taxe.id:
|
||||
taxes_included.append(taxe)
|
||||
for c in pool.get('account.tax').compute(cr, uid, taxes_included, price, 1): # DELETED product = product
|
||||
price+=c['amount']
|
||||
taxes_name.append(c['name'])
|
||||
|
||||
tax_class_id = 1
|
||||
webproduct={
|
||||
'esale_joomla_id': esale_joomla_id,
|
||||
'quantity': pool.get('product.product')._product_virtual_available(cr, uid, [product.id], '', False, {'shop':website.shop_id.id})[product.id],
|
||||
'model': product.code or '',
|
||||
'price': price,
|
||||
'weight': float(0.0),
|
||||
'length': float(0.0),
|
||||
'width': float(0.0),
|
||||
'height': float(0.0),
|
||||
'tax_class_id': tax_class_id,
|
||||
'category_id': categ.esale_joomla_id,
|
||||
}
|
||||
|
||||
|
||||
attach_ids = pool.get('ir.attachment').search(cr, uid, [('res_model','=','product.product'), ('res_id', '=',product.id)])
|
||||
data = pool.get('ir.attachment').read(cr, uid, attach_ids)
|
||||
if len(data):
|
||||
webproduct['haspic'] = 1
|
||||
if not data[0]['link']:
|
||||
webproduct['picture'] = data[0]['datas']
|
||||
else:
|
||||
try:
|
||||
webproduct['picture'] = base64.encodestring(urllib.urlopen(data[0]['link']).read())
|
||||
except:
|
||||
webproduct['haspic'] = 0
|
||||
webproduct['fname'] = data[0]['datas_fname']
|
||||
else:
|
||||
webproduct['haspic'] =0
|
||||
|
||||
webproduct['name'] = str(product.name or '')
|
||||
webproduct['description'] = str((product.description_sale or '') + (len(taxes_name) and ("\n(" + (', '.join(taxes_name)) + ')') or ''))
|
||||
webproduct['short_description'] = str(product.description_sale or '')
|
||||
|
||||
osc_id=server.set_product(webproduct)
|
||||
|
||||
if osc_id!=esale_joomla_id:
|
||||
if esale_joomla_id:
|
||||
pool.get('esale_joomla.product').write(cr, uid, [esale_joomla_id], {'esale_joomla_id': osc_id})
|
||||
prod_update += 1
|
||||
else:
|
||||
pool.get('esale_joomla.product').create(cr, uid, {'product_id': product.id, 'web_id': website.id, 'esale_joomla_id': osc_id, 'name': product.name })
|
||||
prod_new += 1
|
||||
else:
|
||||
prod_update += 1
|
||||
return {'prod_new':prod_new, 'prod_update':prod_update}
|
||||
|
||||
class wiz_esale_joomla_products(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_do_export],
|
||||
'result': {'type': 'form', 'arch': _export_done_form, 'fields': _export_done_fields, 'state': [('end', 'End')] }
|
||||
}
|
||||
}
|
||||
wiz_esale_joomla_products('esale_joomla.products');
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# 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 ir
|
||||
import time
|
||||
import os
|
||||
import netsvc
|
||||
import xmlrpclib
|
||||
import pooler
|
||||
|
||||
import wizard
|
||||
from osv import osv
|
||||
|
||||
_export_form = '''<?xml version="1.0"?>
|
||||
<form string="Initial import" />
|
||||
'''
|
||||
|
||||
_export_fields = {}
|
||||
|
||||
_export_done_form = '''<?xml version="1.0"?>
|
||||
<form string="Initial import">
|
||||
<separator string="Stock succesfully updated" colspan="4" />
|
||||
</form>'''
|
||||
|
||||
_export_done_fields = {}
|
||||
|
||||
def _do_export(self, cr, uid, data, context):
|
||||
self.pool = pooler.get_pool(cr.dbname)
|
||||
ids = self.pool.get('esale_joomla.web').search(cr, uid, [])
|
||||
for website in self.pool.get('esale_joomla.web').browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-synchro.php" % website.url)
|
||||
for osc_product in website.product_ids:
|
||||
if osc_product.esale_joomla_id:
|
||||
webproduct={
|
||||
'esale_joomla_id': osc_product.esale_joomla_id,
|
||||
'quantity': pooler.get_pool(cr.dbname).get('product.product')._product_virtual_available(cr, uid, [osc_product.product_id.id], '', False, {'shop':website.shop_id.id})[osc_product.product_id.id],
|
||||
}
|
||||
osc_id=server.set_product_stock(webproduct)
|
||||
return {}
|
||||
|
||||
class wiz_esale_joomla_stocks(wizard.interface):
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_do_export],
|
||||
'result': { 'type': 'form', 'arch': _export_done_form, 'fields': _export_done_fields, 'state': [('end', 'End')]}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wiz_esale_joomla_stocks('esale_joomla.stocks');
|
|
@ -1,2 +0,0 @@
|
|||
from esale_osc import *
|
||||
import wizard
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name" : "OScommerce Interface / ZenCart",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny / modified by Lucien Moerkamp",
|
||||
"category" : "Interfaces/CMS & eCommerce",
|
||||
"website" : "http://www.tinyerp.com",
|
||||
"depends" : ["product", "stock", "sale"],
|
||||
"description": """OSCommerce (Zencart) eCommerce interface synchronisation.
|
||||
Users can order on the website, orders are automatically imported in Tiny
|
||||
ERP.
|
||||
|
||||
You can export products, stock level and create links between
|
||||
categories of products, taxes and languages.
|
||||
|
||||
If you product has an image attched, it send the image to the Joomla website.""",
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ["esale_osc_view.xml", "esale_osc_wizard.xml"],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
|
@ -1,253 +0,0 @@
|
|||
<?php
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////// ////////////////////
|
||||
/////////////////////// PLEASE CONFIGURE THE RIGHT INCLUDES FOR YOUR CONFIGURATION ////////////////////
|
||||
|
||||
include("xmlrpcutils/xmlrpc.inc");
|
||||
include("xmlrpcutils/xmlrpcs.inc");
|
||||
include("../includes/configure.php");
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$con = mysql_pconnect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD);
|
||||
mysql_select_db(DB_DATABASE);
|
||||
|
||||
function get_taxes() {
|
||||
$taxes=array();
|
||||
|
||||
$result=mysql_query("select tax_class_id, tax_class_title from tax_class;");
|
||||
if ($result) while ($row=mysql_fetch_row($result)) {
|
||||
$taxes[]=new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval($row[1], "string")), "array");
|
||||
}
|
||||
return new xmlrpcresp( new xmlrpcval($taxes, "array"));
|
||||
}
|
||||
|
||||
function get_languages() {
|
||||
$languages=array();
|
||||
|
||||
$result=mysql_query("select languages_id, name from languages;");
|
||||
if ($result) while ($row=mysql_fetch_row($result)) {
|
||||
$languages[]=new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval($row[1], "string")), "array");
|
||||
}
|
||||
return new xmlrpcresp( new xmlrpcval($languages, "array"));
|
||||
}
|
||||
|
||||
function get_categories() {
|
||||
$categories=array();
|
||||
|
||||
$result=mysql_query("select categories_id, min(language_id) from categories_description group by categories_id;");
|
||||
if ($result) while ($row=mysql_fetch_row($result)) {
|
||||
$resultb=mysql_query("select categories_id, categories_name from categories_description where categories_id=".$row[0]." and language_id=".$row[1].";");
|
||||
if ($resultb and $row=mysql_fetch_row($resultb)) {
|
||||
$categories[]=new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval(parent_category($row[0],$row[1]), "string")), "array");
|
||||
}
|
||||
}
|
||||
return new xmlrpcresp( new xmlrpcval($categories, "array"));
|
||||
}
|
||||
|
||||
function parent_category($id, $name) {
|
||||
$result=mysql_query("select parent_id from categories where categories_id=".$id.";");
|
||||
if ($result && $row=mysql_fetch_row($result)) {
|
||||
if ($row[0]==0) {
|
||||
return $name;
|
||||
} else {
|
||||
$resultb=mysql_query("select min(language_id) from categories_description where categories_id=".$row[0].";");
|
||||
if ($resultb && $rowb=mysql_fetch_row($resultb)) {
|
||||
$resultb=mysql_query("select categories_name from categories_description where categories_id=".$row[0]." and language_id=".$rowb[0].";\n");
|
||||
if ($resultb && $rowb=mysql_fetch_row($resultb)) {
|
||||
$name=parent_category($row[0], $rowb[0] . " \\ ". $name);
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
function set_product_stock($tiny_product){
|
||||
mysql_query("update products set products_quantity=".$tiny_product['quantity']." where products_id=".$tiny_product['product_id'].";");
|
||||
mysql_query("update products set products_status=".(($tiny_product['quantity']>0)?1:0)." where products_id=".$tiny_product['product_id'].";");
|
||||
return new xmlrpcresp(new xmlrpcval(0,"int"));
|
||||
}
|
||||
|
||||
function set_product($tiny_product){
|
||||
$lang_id=1;
|
||||
$id_exist=0;
|
||||
////////Check for existance of product_id ///////////
|
||||
$result =mysql_query("select products_id from products where (products_id=".$tiny_product['product_id'].");");
|
||||
if ($result && $row=mysql_fetch_row($result)) {
|
||||
$id_exist=1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////// CHECK FOR oscommerce if "DEFAULT_LANGUAGE" must not be "DEFAULT LANGUAGE" ///////////////////////////////
|
||||
/////////////// //////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
$result =mysql_query("select l.languages_id from languages as l configuration as c where
|
||||
c.configuration_key='DEFAULT_LANGUAGE' and c.configuration_value=l.code;");
|
||||
|
||||
if ($result && $row=mysql_fetch_row($result)) {
|
||||
$lang_id=$row[0];
|
||||
}
|
||||
if ($tiny_product['quantity']>0) {
|
||||
$tiny_product['status']=1;
|
||||
} else {
|
||||
$tiny_product['status']=0;
|
||||
}
|
||||
if ($id_exist==0) {
|
||||
mysql_query("insert into products (products_quantity, products_model, products_price, products_weight, products_tax_class_id, products_status, products_date_added) values (".$tiny_product['quantity'].", '". $tiny_product['model']."', ".$tiny_product['price'].", ".$tiny_product['weight'].", ".$tiny_product['tax_class_id'].", ".$tiny_product['status'].", now());");
|
||||
$osc_id=mysql_insert_id();
|
||||
mysql_query("insert into products_description (products_id, language_id, products_name, products_description) values (".$osc_id.", ".$lang_id.", '".$tiny_product['name']."', '".$tiny_product['description']."');");
|
||||
mysql_query("insert into products_to_categories (categories_id, products_id) values(".$tiny_product['category_id'].",".$osc_id.");");
|
||||
foreach ($tiny_product['langs'] as $lang=>$values) {
|
||||
mysql_query("insert into products_description(products_id, language_id, products_name, products_description)
|
||||
values (".$osc_id.", ".$lang.", '".$values['name']."', '".$values['description']."');");
|
||||
}
|
||||
} else {
|
||||
$osc_id=$tiny_product['product_id'];
|
||||
foreach (array('quantity', 'price', 'weight', 'tax_class_id', 'status') as $key) {
|
||||
mysql_query("update products set products_".$key."=".$tiny_product[$key]." where products_id=".$osc_id.";");
|
||||
}
|
||||
mysql_query("update products set products_model='".$tiny_product['model']."' where products_id=".$osc_id.";");
|
||||
foreach (array('name', 'description') as $key) {
|
||||
mysql_query("update products_description set products_".$key."='".$tiny_product[$key]."' where products_id=".$osc_id." and language_id=".$lang_id.";");
|
||||
}
|
||||
mysql_query("update products_to_categories set categories_id=".$tiny_product['category_id']." where products_id=".$osc_id.";");
|
||||
foreach ($tiny_product['langs'] as $lang=>$values) {
|
||||
mysql_query("delete from products_description where products_id=".$osc_id." and language_id=".$lang.";");
|
||||
mysql_query("insert into products_description(products_id, language_id, products_name, products_description)
|
||||
values (".$osc_id.", ".$lang.", '".$values['name']."', '".$values['description']."');");
|
||||
}
|
||||
}
|
||||
|
||||
$cpt=0;
|
||||
if ($tiny_product['haspic']==1) {
|
||||
if (file_exists('../../images/'.$cpt.'-'.$tiny_product['fname'])) {
|
||||
unlink('../../images/'.$cpt.'-'.$tiny_product['fname']); // DELETE THE EXISTING IMAGES
|
||||
}
|
||||
if ($hd=fopen('../../images/'.$cpt.'-'.$tiny_product['fname'], "w")){
|
||||
fwrite($hd, base64_decode($tiny_product['picture']));
|
||||
fclose($hd);
|
||||
mysql_query("update products set products_image='".$cpt."-".$tiny_product['fname']."' where
|
||||
products_id=".$osc_id.";");
|
||||
|
||||
}
|
||||
}
|
||||
return new xmlrpcresp(new xmlrpcval($osc_id, "int"));
|
||||
}
|
||||
|
||||
function get_saleorders($last_so) {
|
||||
$saleorders=array();
|
||||
$result=mysql_query("SELECT `orders_id` , `customers_name` , `customers_street_address` , `customers_city` , `customers_postcode` , `customers_state` , `customers_country` , `customers_telephone` , `customers_email_address` , `delivery_name` , `delivery_street_address` , `delivery_city` , `delivery_postcode` , `delivery_state` , `delivery_country` , `billing_name` , `billing_street_address` , `billing_city` , `billing_postcode` , `billing_state` , `billing_country` , `date_purchased` , `orders_status`, `customers_id` FROM `orders` where (orders_id > ".$last_so." and orders_status = 1);");
|
||||
|
||||
if ($result){
|
||||
while ($row=mysql_fetch_row($result)) {
|
||||
$orderlines=array();
|
||||
$resultb=mysql_query("select products_id, products_quantity, final_price from orders_products where orders_id=".$row[0].";");
|
||||
if ($resultb){
|
||||
while ($rowb=mysql_fetch_row($resultb)) {
|
||||
$orderlines[]=new xmlrpcval( array("product_id" => new xmlrpcval($rowb[0], "int"),
|
||||
"product_qty" => new xmlrpcval($rowb[1], "int"),
|
||||
"price" => new xmlrpcval($rowb[2], "int")
|
||||
), "struct");
|
||||
}
|
||||
}
|
||||
$note="no note";
|
||||
$saleorders[] = new xmlrpcval( array("id" => new xmlrpcval( $row[0], "int"),
|
||||
"note" => new xmlrpcval( $note, "string" ),
|
||||
"lines" => new xmlrpcval( $orderlines, "array"),
|
||||
"address" => new xmlrpcval( array( "name" => new xmlrpcval($row[1], "string"),
|
||||
"address" => new xmlrpcval($row[2], "string"),
|
||||
"city" => new xmlrpcval($row[3], "string"),
|
||||
"zip" => new xmlrpcval($row[4], "string"),
|
||||
"state" => new xmlrpcval($row[5], "string"),
|
||||
"country" => new xmlrpcval($row[6], "string"),
|
||||
"phone" => new xmlrpcval($row[7], "string"),
|
||||
"email" => new xmlrpcval($row[8], "string"),
|
||||
"esale_id" => new xmlrpcval($row[23], "string")
|
||||
), "struct"),
|
||||
"delivery" => new xmlrpcval( array( "name" => new xmlrpcval($row[9], "string"),
|
||||
"address" => new xmlrpcval($row[10], "string"),
|
||||
"city" => new xmlrpcval($row[11], "string"),
|
||||
"zip" => new xmlrpcval($row[12], "string"),
|
||||
"state" => new xmlrpcval($row[13], "string"),
|
||||
"country" => new xmlrpcval($row[14], "string"),
|
||||
"email" => new xmlrpcval($row[8], "string"),
|
||||
"esale_id" => new xmlrpcval($row[23], "string")
|
||||
), "struct"),
|
||||
"billing" => new xmlrpcval( array( "name" => new xmlrpcval($row[15], "string"),
|
||||
"address" => new xmlrpcval($row[16], "string"),
|
||||
"city" => new xmlrpcval($row[17], "string"),
|
||||
"zip" => new xmlrpcval($row[18], "string"),
|
||||
"state" => new xmlrpcval($row[19], "string"),
|
||||
"country" => new xmlrpcval($row[20], "string"),
|
||||
"email" => new xmlrpcval($row[8], "string"),
|
||||
"esale_id" => new xmlrpcval($row[23], "string")
|
||||
), "struct"),
|
||||
"date" => new xmlrpcval( $row[21], "string")
|
||||
), "struct");
|
||||
}
|
||||
}
|
||||
return new xmlrpcresp(new xmlrpcval($saleorders, "array"));
|
||||
}
|
||||
|
||||
|
||||
function get_min_open_orders($last_so) {
|
||||
$result=mysql_query("SELECT min(`orders_id`) as min FROM `orders` where (orders_id <= ".$last_so.") and (orders_status = 2);");
|
||||
if ($result) {
|
||||
$min=mysql_fetch_row($result);
|
||||
return new xmlrpcresp( new xmlrpcval($min[0], "int"));
|
||||
}
|
||||
else return new xmlrpcresp( new xmlrpcval(-1, "int"));
|
||||
}
|
||||
|
||||
function close_open_orders($order_id) {
|
||||
mysql_query("update orders set orders_status=3 where orders_id=".$order_id.";");
|
||||
return new xmlrpcresp(new xmlrpcval(0, "int"));
|
||||
}
|
||||
|
||||
|
||||
function process_order($order_id) {
|
||||
mysql_query("update orders set orders_status=2 where orders_id=".$order_id.";");
|
||||
return new xmlrpcresp(new xmlrpcval(0, "int"));
|
||||
}
|
||||
|
||||
$server = new xmlrpc_server( array( "get_taxes" => array( "function" => "get_taxes",
|
||||
"signature" => array( array($xmlrpcArray)
|
||||
)
|
||||
),
|
||||
"get_languages" => array( "function" => "get_languages",
|
||||
"signature" => array( array($xmlrpcArray)
|
||||
)
|
||||
),
|
||||
"get_categories" => array( "function" => "get_categories",
|
||||
"signature" => array( array($xmlrpcArray)
|
||||
)
|
||||
),
|
||||
"get_saleorders" => array( "function" => "get_saleorders",
|
||||
"signature" => array( array($xmlrpcArray, $xmlrpcInt)
|
||||
)
|
||||
),
|
||||
"get_min_open_orders" => array( "function" => "get_min_open_orders",
|
||||
"signature" => array( array($xmlrpcInt, $xmlrpcInt)
|
||||
)
|
||||
),
|
||||
"set_product" => array( "function" => "set_product",
|
||||
"signature" => array( array($xmlrpcInt, $xmlrpcStruct)
|
||||
)
|
||||
),
|
||||
"set_product_stock" => array( "function" => "set_product_stock",
|
||||
"signature" => array( array($xmlrpcInt, $xmlrpcStruct)
|
||||
)
|
||||
),
|
||||
"process_order" => array( "function" => "process_order",
|
||||
"signature" => array( array($xmlrpcInt, $xmlrpcInt)
|
||||
)
|
||||
),
|
||||
"close_open_orders" => array( "function" => "close_open_orders",
|
||||
"signature" => array( array($xmlrpcInt, $xmlrpcInt)
|
||||
)
|
||||
)
|
||||
), false);
|
||||
$server->functions_parameters_type= 'phpvals';
|
||||
$server->service();
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,217 +0,0 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: sale.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# 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 netsvc
|
||||
from osv import fields,osv,orm
|
||||
import ir
|
||||
|
||||
import time
|
||||
import xmlrpclib
|
||||
from mx import DateTime
|
||||
|
||||
class esale_osc_web(osv.osv):
|
||||
_name = "esale_osc.web"
|
||||
_description = "OScommerce Website"
|
||||
_columns = {
|
||||
'name': fields.char('Name',size=64, required=True),
|
||||
'url': fields.char('URL', size=64, required=True),
|
||||
'shop_id': fields.many2one('sale.shop', 'Sale Shop', required=True),
|
||||
'partner_anonymous_id': fields.many2one('res.partner', 'Anonymous', required=True),
|
||||
'active': fields.boolean('Active'),
|
||||
'product_ids': fields.one2many('esale_osc.product', 'web_id', 'Web Products'),
|
||||
'language_ids': fields.one2many('esale_osc.lang', 'web_id', 'Languages'),
|
||||
'tax_ids': fields.one2many('esale_osc.tax', 'web_id', 'Taxes'),
|
||||
'category_ids': fields.one2many('esale_osc.category', 'web_id', 'Categories'),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: 1
|
||||
}
|
||||
|
||||
def add_all_products(self, cr, uid, ids, *args):
|
||||
product_pool=self.pool.get('esale_osc.product')
|
||||
for id in ids:
|
||||
cr.execute("select p.id from product_product as p left join esale_osc_product as o on p.id=o.product_id and o.web_id=%d where o.id is NULL;" % id)
|
||||
for [product] in cr.fetchall():
|
||||
value={ 'product_id' : product,
|
||||
'web_id' : id
|
||||
}
|
||||
value.update(product_pool.onchange_product_id(cr, uid, [], product, id)['value'])
|
||||
product_pool.create(cr, uid, value)
|
||||
return True
|
||||
|
||||
def tax_import(self, cr, uid, ids, *args):
|
||||
for website in self.browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-syncro.php" % website.url)
|
||||
taxes = server.get_taxes()
|
||||
for tax in taxes:
|
||||
value={
|
||||
'web_id' : website.id,
|
||||
'esale_osc_id' : tax[0],
|
||||
'name' : tax[1]
|
||||
}
|
||||
self.pool.get('esale_osc.tax').create(cr, uid, value)
|
||||
return True
|
||||
|
||||
def lang_import(self, cr, uid, ids, *args):
|
||||
for website in self.browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-syncro.php" % website.url)
|
||||
languages = server.get_languages()
|
||||
for language in languages:
|
||||
value={ 'web_id' : website.id,
|
||||
'esale_osc_id' : language[0],
|
||||
'name' : language[1]
|
||||
}
|
||||
self.pool.get('esale_osc.lang').create(cr, uid, value)
|
||||
return True
|
||||
|
||||
def category_import(self, cr, uid, ids, *args):
|
||||
for website in self.browse(cr, uid, ids):
|
||||
server = xmlrpclib.ServerProxy("%s/tinyerp-syncro.php" % website.url)
|
||||
categories = server.get_categories()
|
||||
category_pool = self.pool.get('esale_osc.category')
|
||||
for category in categories:
|
||||
value={ 'web_id' : website.id,
|
||||
'esale_osc_id' : category[0],
|
||||
'name' : category[1]
|
||||
}
|
||||
existing = category_pool.search(cr, uid, [('web_id','=',website.id), ('esale_osc_id', '=', category[0])])
|
||||
if len(existing)>0:
|
||||
category_pool.write(cr, uid, existing, value)
|
||||
else:
|
||||
category_pool.create(cr, uid, value)
|
||||
return True
|
||||
|
||||
esale_osc_web()
|
||||
|
||||
class esale_osc_tax(osv.osv):
|
||||
_name = "esale_osc.tax"
|
||||
_description = "esale_osc Tax"
|
||||
_columns = {
|
||||
'name' : fields.char('Tax name', size=32, required=True),
|
||||
'esale_osc_id' : fields.integer('esale_osc ID'),
|
||||
'tax_id' : fields.many2one('account.tax', 'Tax'),
|
||||
'web_id' : fields.many2one('esale_osc.web', 'Website')
|
||||
}
|
||||
esale_osc_tax()
|
||||
|
||||
class esale_osc_category(osv.osv):
|
||||
_name = "esale_osc.category"
|
||||
_description = "esale_osc Category"
|
||||
_columns = { 'name' : fields.char('Name', size=64, reuired=True),
|
||||
'esale_osc_id' : fields.integer('esale_osc ID', required=True),
|
||||
'web_id' : fields.many2one('esale_osc.web', 'Website'),
|
||||
'category_id' : fields.many2one('product.category', 'Category'),
|
||||
}
|
||||
esale_osc_category()
|
||||
|
||||
class esale_osc_product(osv.osv):
|
||||
_name = "esale_osc.product"
|
||||
_description = "esale_osc Product"
|
||||
_columns = { 'web_id' : fields.many2one('esale_osc.web', 'Web Ref'),
|
||||
'name' : fields.char('Name', size=64, required=True),
|
||||
'product_id' : fields.many2one('product.product', 'Product', required=True),
|
||||
'esale_osc_id' : fields.integer('esale_osc product id'),
|
||||
'esale_osc_tax_id' : fields.many2one('esale_osc.tax', 'esale_osc tax'),
|
||||
}
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, web_id):
|
||||
value={}
|
||||
if (product_id):
|
||||
product=self.pool.get('product.product').browse(cr, uid, product_id)
|
||||
value['name']=product.name
|
||||
return {'value': value}
|
||||
esale_osc_product()
|
||||
|
||||
class esale_osc_language(osv.osv):
|
||||
_name = "esale_osc.lang"
|
||||
_description = "esale_osc Language"
|
||||
_columns = { 'name' : fields.char('Name', size=32, required=True),
|
||||
'esale_osc_id' : fields.integer('esale_osc ID', required=True),
|
||||
'language_id' : fields.many2one('res.lang', 'Language'),
|
||||
'web_id' : fields.many2one('esale_osc.web', 'Website')
|
||||
}
|
||||
esale_osc_language()
|
||||
|
||||
class esale_osc_saleorder(osv.osv):
|
||||
_inherit='sale.order'
|
||||
_name='sale.order'
|
||||
_table='sale_order'
|
||||
_columns = {
|
||||
'esale_osc_web': fields.many2one('esale_osc.web', 'Website'),
|
||||
'esale_osc_id': fields.integer('esale_osc Id'),
|
||||
}
|
||||
_defaults = {
|
||||
'esale_osc_id': lambda *a: False,
|
||||
}
|
||||
|
||||
def onchange_esale_osc_web(self, cr, uid, ids, esale_osc_web):
|
||||
value={}
|
||||
if esale_osc_web:
|
||||
web=self.pool.get('esale_osc.web').browse(cr, uid, esale_osc_web)
|
||||
value['shop_id']=web.shop_id.id
|
||||
value['partner_id']=web.partner_anonymous_id.id
|
||||
value.update(self.pool.get('sale.order').onchange_shop_id(cr, uid, ids, value['shop_id'])['value'])
|
||||
value.update(self.pool.get('sale.order').onchange_partner_id(cr, uid, ids, value['partner_id'])['value'])
|
||||
|
||||
return {'value':value}
|
||||
|
||||
def order_create(self, cr, uid, ids, context={}):
|
||||
for order in self.browse(cr, uid, ids, context):
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [order.partner_id.id], ['delivery','invoice','contact'])
|
||||
pricelist_id=order.partner_id.property_product_pricelist.id
|
||||
order_lines = []
|
||||
for line in order.order_lines:
|
||||
order_lines.append( (0,0,{
|
||||
'name': line.name,
|
||||
'product_qty': line.product_qty,
|
||||
'date_planned': line.date_planned,
|
||||
'product_id': line.product_id.id,
|
||||
'product_uom': line.product_uom.id,
|
||||
'price_unit': line.price_unit,
|
||||
'type': line.product_id.procure_method
|
||||
}) )
|
||||
order_id = self.pool.get('sale.order').create(cr, uid, {
|
||||
'name': order.name,
|
||||
'shop_id': order.web_id.shop_id.id,
|
||||
'origin': 'WEB:'+str(order.id),
|
||||
'date_order': order.date_order,
|
||||
'user_id': uid,
|
||||
'partner_id': order.partner_id.id,
|
||||
'partner_invoice_id':addr['invoice'],
|
||||
'partner_order_id':addr['contact'],
|
||||
'partner_shipping_id':addr['delivery'],
|
||||
'pricelist_id': pricelist_id,
|
||||
'order_line': order_lines
|
||||
})
|
||||
self.write(cr, uid, [order.id], {'state':'done', 'order_id': order_id})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'sale.order', order_id, 'order_confirm', cr)
|
||||
return True
|
||||
|
||||
esale_osc_saleorder()
|
|
@ -1,201 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Sales Management/Internet Sales" id="menu_esale_osc_root"/>
|
||||
|
||||
<record model="ir.ui.view" id="view_esale_osc_form">
|
||||
<field name="name">esale_osc.web.form</field>
|
||||
<field name="model">esale_osc.web</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="esale_osc Web Shop">
|
||||
<notebook>
|
||||
<page string="General Informations">
|
||||
<separator string="esale_osc Shop Info" colspan="4"/>
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<field name="url" widget="url" required="1"/>
|
||||
<field name="active" select="1"/>
|
||||
<field name="shop_id" select="1" required="1"/>
|
||||
<field name="partner_anonymous_id" required="1"/>
|
||||
<label string="Proceed with the mappings BEFORE the definitions of the active products!!" colspan="4"/>
|
||||
<separator string="Active Products" colspan="4"/>
|
||||
<button name="add_all_products" string="Add all products" type="object"/>
|
||||
<field name="product_ids" colspan="4" view="esale_osc.product.web.form" widget="one2many_list" />
|
||||
</page>
|
||||
<page string="Taxes Mapping">
|
||||
<button type="object" string="Import Taxes" name="tax_import"/>
|
||||
<field colspan="4" name="tax_ids" widget="one2many_list" view="esale_osc.tax.web.form"/>
|
||||
</page>
|
||||
<page string="Languages Mapping">
|
||||
<button type="object" string="Import Languages" name="lang_import"/>
|
||||
<field colspan="4" name="language_ids" widget="one2many_list" view="esale_osc.language.web.form"/>
|
||||
</page>
|
||||
<page string="Categories Mapping">
|
||||
<button type="object" string="Import categories" name="category_import"/>
|
||||
<field colspan="4" name="category_ids" widget="one2many_list" view="esale_osc.category.web.form"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_esale_osc_form">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">esale_osc.web</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_esale_osc_form"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Sales Management/Internet Sales/Websites" id="menu_action_esale_osc_web" action="action_esale_osc_form" groups="admin"/>
|
||||
|
||||
<record model="ir.ui.view" id="esale_osc_language_web_form">
|
||||
<field name="name">esale_osc.language.web.form</field>
|
||||
<field name="model">esale_osc.lang</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Language">
|
||||
<separator colspan="4" string="Language mapping"/>
|
||||
<field colspan="4" name="name" select="1" required="1"/>
|
||||
<field name="language_id" select="1"/>
|
||||
<field name="esale_osc_id" readonly="1" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="esale_osc_tax_web_form">
|
||||
<field name="name">esale_osc.tax.web.form</field>
|
||||
<field name="model">esale_osc.tax</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Taxes">
|
||||
<separator colspan="4" string="Taxes mapping"/>
|
||||
<field colspan="4" name="name" select="1" required="1"/>
|
||||
<field name="tax_id" select="1"/>
|
||||
<field name="esale_osc_id" readonly="1" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="esale_osc_category_web_form">
|
||||
<field name="name">esale_osc.category.web.form</field>
|
||||
<field name="model">esale_osc.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Categories">
|
||||
<separator colspan="4" string="taxes"/>
|
||||
<field name="name" select="1" colspan="4" required="1"/>
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="esale_osc_id" select="1" readonly="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="esale_osc_product_web_form">
|
||||
<field name="name">esale_osc.product.web.form</field>
|
||||
<field name="model">esale_osc.product</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Product">
|
||||
<separator colspan="4" string="Product Information"/>
|
||||
<field name="name" colspan="4" select="1" required="1"/>
|
||||
<field name="product_id" on_change="onchange_product_id(product_id, web_id)" select="1" required="1"/>
|
||||
<field name="esale_osc_id" readonly="1" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="esale_osc_saleorder_tree">
|
||||
<field name="name">esale_osc.saleorder.tree</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sales Orders">
|
||||
<field name="name"/>
|
||||
<field name="shipped"/>
|
||||
<field name="esale_osc_id"/>
|
||||
<field name="esale_osc_web"/>
|
||||
<field name="invoiced"/>
|
||||
<field name="date_order"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="partner_shipping_id"/>
|
||||
<field name="amount_untaxed"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="esale_osc_saleorder_form">
|
||||
<field name="name">esale_osc.saleorder.form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sales Order">
|
||||
<notebook>
|
||||
<page string="Order Line">
|
||||
<field name="name" select="1"/>
|
||||
<group col="4" colspan="2">
|
||||
<field name="shipped" select="1"/>
|
||||
<field name="invoiced" select="1"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="esale_osc_id" select="1"/>
|
||||
<field name="esale_osc_web" on_change="onchange_esale_osc_web(esale_osc_web)" select="1"/>
|
||||
<field name="date_order" select="1"/>
|
||||
<field name="shop_id" on_change="onchange_shop_id(shop_id)" select="1"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)" required="1" select="1"/>
|
||||
<field domain="[('partner_id','=',partner_id)]" name="partner_order_id"/>
|
||||
<field domain="[('partner_id','=',partner_id)]" name="partner_invoice_id"/>
|
||||
<field domain="[('partner_id','=',partner_id)]" name="partner_shipping_id"/>
|
||||
<field domain="[('type','=','sale')]" name="pricelist_id"/>
|
||||
<field name="project_id" select="1"/>
|
||||
<newline/>
|
||||
<field colspan="4" name="order_line" nolabel="1" widget="one2many_list"/>
|
||||
<newline/>
|
||||
<group col="7" colspan="4">
|
||||
<field name="amount_untaxed"/>
|
||||
<field name="amount_tax"/>
|
||||
<field name="amount_total"/>
|
||||
<button name="button_dummy" states="draft" string="Compute" type="object"/>
|
||||
</group>
|
||||
<group col="13" colspan="4">
|
||||
<field name="state" select="1"/>
|
||||
<button name="order_confirm" states="draft" string="Confirm Order"/>
|
||||
<button name="osc_action_cancel" states="manual,progress" string="Cancel Order" type="object"/>
|
||||
<button name="cancel" states="draft" string="Cancel Order"/>
|
||||
<button name="invoice_cancel" states="invoice_except" string="Cancel Order"/>
|
||||
<button name="invoice_recreate" states="invoice_except" string="Recreate Invoice"/>
|
||||
<button name="invoice_corrected" states="invoice_except" string="Invoice Corrected"/>
|
||||
<button name="ship_cancel" states="shipping_except" string="Cancel Order"/>
|
||||
<button name="ship_recreate" states="shipping_except" string="Recreate Procurement"/>
|
||||
<button name="ship_corrected" states="shipping_except" string="Procurement Corrected"/>
|
||||
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
|
||||
<button name="manual_invoice" states="manual" string="Create Invoice"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Other data">
|
||||
<field name="incoterm"/>
|
||||
<field name="picking_policy" required="True"/>
|
||||
<field name="user_id"/>
|
||||
<field name="order_policy"/>
|
||||
<field name="origin"/>
|
||||
<field name="invoice_quantity"/>
|
||||
<field name="client_order_ref"/>
|
||||
<separator colspan="4" string="Notes"/>
|
||||
<field colspan="4" name="note" nolabel="1"/>
|
||||
</page>
|
||||
<page string="History">
|
||||
<separator colspan="4" string="Related invoices"/>
|
||||
<field colspan="4" name="invoice_ids" nolabel="1"/>
|
||||
<separator colspan="4" string="Related packings"/>
|
||||
<field colspan="4" name="picking_ids" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_saleorder_form">
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sale.order</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="esale_osc_saleorder_form"/>
|
||||
<field name="domain">[('esale_osc_id','!=', 0)]</field>
|
||||
</record>
|
||||
<menuitem name="Sales Management/Internet Sales/Sale Orders" id="menu_action_esale_osc_saleorder" action="action_saleorder_form" groups="admin"/>
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<wizard string="Export products" model="esale_osc.web" name="esale_osc.products"
|
||||
id="wizard_esale_osc_products"/>
|
||||
<wizard string="Update stocks" model="esale_osc.web" name="esale_osc.stocks"
|
||||
id="wizard_esale_osc_stocks"/>
|
||||
<wizard string="Import sale orders" model="esale_osc.web" name="esale_osc.saleorders"
|
||||
id="wizard_esale_osc_saleorders"/>
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<record model="workflow" id="wkf_osc_sale">
|
||||
<field name="name">esale_osc.saleorder.basic</field>
|
||||
<field name="osv">esale_osc.saleorder</field>
|
||||
<field name="on_create">True</field>
|
||||
</record>
|
||||
|
||||
#----------------------------------------------
|
||||
# Activity
|
||||
#----------------------------------------------
|
||||
<record model="workflow.activity" id="act_draft">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="flow_start">True</field>
|
||||
<field name="name">draft</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_router">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">router</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">action_wait()</field>
|
||||
<field name="split_mode">OR</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_wait_invoice">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">wait_invoice</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_wait_ship">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">wait_ship</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_done">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">done</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'done'})</field>
|
||||
<field name="join_mode">AND</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_cancel">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">cancel</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="action">action_cancel()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_cancel2">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">cancel2</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="action">action_cancel()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_cancel3">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">cancel3</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="action">action_cancel()</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_invoice">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">invoice</field>
|
||||
<field name="kind">subflow</field>
|
||||
<field name="subflow_id" search="[('name','=','account.invoice.basic')]"/>
|
||||
<field name="action">action_invoice_create()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_invoice_except">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">invoice_except</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'invoice_except', 'invoice_id':False})</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_invoice_end">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">invoice_end</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'invoiced':1})</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_invoice_cancel">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">invoice_cancel</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="action">action_cancel()</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_ship">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">ship</field>
|
||||
<field name="kind">function</field>
|
||||
<!--
|
||||
<field name="kind">subflow</field>
|
||||
<field name="subflow_id" search="[('osv','=','stock.picking')]"/>
|
||||
-->
|
||||
<field name="action">action_ship_create()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_ship_except">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">ship_except</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'shipping_except'})</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_ship_end">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">ship_end</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">action_ship_end()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="act_ship_cancel">
|
||||
<field name="wkf_id" ref="wkf_osc_sale"/>
|
||||
<field name="name">ship_cancel</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="action">action_cancel()</field>
|
||||
</record>
|
||||
|
||||
#----------------------------------------------
|
||||
# Transistion
|
||||
#----------------------------------------------
|
||||
|
||||
<record model="workflow.transition" id="trans_invoice_end_done">
|
||||
<field name="act_from" ref="act_invoice_end"/>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_draft_router">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_router"/>
|
||||
<field name="signal">order_confirm</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_draft_cancel">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_router_wait_invoice">
|
||||
<field name="act_from" ref="act_router"/>
|
||||
<field name="act_to" ref="act_wait_invoice"/>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_router_wait_ship">
|
||||
<field name="act_from" ref="act_router"/>
|
||||
<field name="act_to" ref="act_wait_ship"/>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_wait_invoice_cancel2">
|
||||
<field name="act_from" ref="act_wait_invoice"/>
|
||||
<field name="act_to" ref="act_cancel2"/>
|
||||
<field name="signal">cancel</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_wait_ship_cancel3">
|
||||
<field name="act_from" ref="act_wait_ship"/>
|
||||
<field name="act_to" ref="act_cancel3"/>
|
||||
<field name="signal">cancel</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_wait_ship_ship">
|
||||
<field name="act_from" ref="act_wait_ship"/>
|
||||
<field name="act_to" ref="act_ship"/>
|
||||
<field name="condition">(order_policy!='prepaid') or invoiced</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_wait_invoice_invoice">
|
||||
<field name="act_from" ref="act_wait_invoice"/>
|
||||
<field name="act_to" ref="act_invoice"/>
|
||||
<field name="condition">(order_policy=='prepaid') or ((order_policy=='postpaid') and shipped)</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_wait_invoice_invoice_manual">
|
||||
<field name="act_from" ref="act_wait_invoice"/>
|
||||
<field name="act_to" ref="act_invoice"/>
|
||||
<field name="signal">manual_invoice</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_invoice_invoice_end">
|
||||
<field name="act_from" ref="act_invoice"/>
|
||||
<field name="act_to" ref="act_invoice_end"/>
|
||||
<field name="signal">subflow.paid</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_invoice_invoice_except">
|
||||
<field name="act_from" ref="act_invoice"/>
|
||||
<field name="act_to" ref="act_invoice_except"/>
|
||||
<field name="signal">subflow.cancel</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_invoice_except_invoice">
|
||||
<field name="act_from" ref="act_invoice_except"/>
|
||||
<field name="act_to" ref="act_invoice"/>
|
||||
<field name="signal">invoice_recreate</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_invoice_except_invoice_end">
|
||||
<field name="act_from" ref="act_invoice_except"/>
|
||||
<field name="act_to" ref="act_invoice_end"/>
|
||||
<field name="signal">invoice_corrected</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_invoice_except_invoice_cancel">
|
||||
<field name="act_from" ref="act_invoice_except"/>
|
||||
<field name="act_to" ref="act_invoice_cancel"/>
|
||||
<field name="signal">invoice_cancel</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_ship_end_done">
|
||||
<field name="act_from" ref="act_ship_end"/>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_ship_ship_end">
|
||||
<field name="act_from" ref="act_ship"/>
|
||||
<field name="act_to" ref="act_ship_end"/>
|
||||
<field name="trigger_model">mrp.procurement</field>
|
||||
<field name="trigger_expr_id">procurement_lines_get()</field>
|
||||
<field name="condition">test_procurement_finnished()</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_ship_ship_except">
|
||||
<field name="act_from" ref="act_ship"/>
|
||||
<field name="act_to" ref="act_ship_except"/>
|
||||
<field name="condition">test_procurement_finnished('cancel')</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_ship_except_ship">
|
||||
<field name="act_from" ref="act_ship_except"/>
|
||||
<field name="act_to" ref="act_ship"/>
|
||||
<field name="signal">ship_recreate</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_">
|
||||
<field name="act_from" ref="act_ship_except"/>
|
||||
<field name="act_to" ref="act_ship_end"/>
|
||||
<field name="signal">ship_corrected</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="trans_ship_except_ship_cancel">
|
||||
<field name="act_from" ref="act_ship_except"/>
|
||||
<field name="act_to" ref="act_ship_cancel"/>
|
||||
<field name="signal">ship_cancel</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -1,3 +0,0 @@
|
|||
import wizard_esale_osc_export_products
|
||||
import wizard_esale_osc_import_sos
|
||||
import wizard_esale_osc_update_stocks
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue