[MERGE] forward port of branch 7.0 up to revid 9382 chs@openerp.com-20130823131214-ipouwtnz8r16mlvv

bzr revid: chs@openerp.com-20130823143114-83tdjhbsdes0kydr
This commit is contained in:
Christophe Simonis 2013-08-23 16:31:14 +02:00
commit 58868227f9
29 changed files with 439 additions and 75 deletions

View File

@ -884,6 +884,8 @@ class account_voucher(osv.osv):
return res
def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, date, amount, ttype, company_id, context=None):
if context is None:
context = {}
if not journal_id:
return False
journal_pool = self.pool.get('account.journal')

View File

@ -42,6 +42,7 @@ class analytic_user_funct_grid(osv.osv):
return {}
value = {}
prod = False
if product_id:
prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
emp = emp_obj.browse(cr, uid, emp_id[0], context=context)

View File

@ -35,6 +35,16 @@ class lunch_order(osv.Model):
_description = 'Lunch Order'
_order = 'date desc'
def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
res = []
for elmt in self.browse(cr, uid, ids, context=context):
name = _("Lunch Order")
name = name + ' ' + str(elmt.id)
res.append((elmt.id, name))
return res
def _price_get(self, cr, uid, ids, name, arg, context=None):
"""
get and sum the order lines' price

View File

@ -7,7 +7,7 @@
<menuitem name="Administrate Orders" parent="menu_lunch" id="menu_lunch_admin" sequence="51" groups="group_lunch_manager"/>
<menuitem name="Administrate Cash Moves" parent="menu_lunch" id="menu_lunch_cash" sequence="52" groups="group_lunch_manager"/>
<menuitem name="Configuration" parent="menu_lunch" id="menu_lunch_config" sequence="53" groups="group_lunch_manager"/>
<!--View Search to group/filter by Supplier and time-->
<record model="ir.ui.view" id="lunch_order_line_search_view">
<field name="name">Search</field>
@ -85,6 +85,40 @@
</field>
</record>
<!--view for cashmove-->
<record model="ir.ui.view" id="casmove_tree_view">
<field name="name">cashmove tree</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<tree string="cashmove tree">
<field name="date"/>
<field name="user_id"/>
<field name="description"/>
<field name="amount" sum="Total"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="casmove_form_view">
<field name="name">cashmove form</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<form string="cashmove form" version="7.0">
<sheet>
<group>
<field name="user_id"
context="{'default_groups_ref': ['base.group_user', 'lunch.group_lunch_user']}"/>
<field name="date"/>
<field name="amount"/>
</group>
<label for='description'/>
<field name="description"/>
</sheet>
</form>
</field>
</record>
<!--Action for Your Orders-->
<record model="ir.actions.act_window" id="action_lunch_order_form">
<field name="name">New Order</field>
@ -111,6 +145,19 @@
</field>
</record>
<menuitem name="Previous Orders" parent="menu_lunch_title" id="menu_lunch_order_tree" action="action_lunch_order_tree" sequence="2"/>
<record model="ir.ui.view" id="casmove_tree">
<field name="name">cashmove tree</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<tree string="cashmove tree" version="7.0" create='false'>
<field name="date"/>
<field name="user_id"/>
<field name="description"/>
<field name="amount" sum="Total"/>
</tree>
</field>
</record>
<!--Action for Lunch cashmoves-->
<record model="ir.actions.act_window" id="action_lunch_cashmove_form">
@ -119,6 +166,7 @@
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_lunch_employee_payment_filter"/>
<field name="context">{"search_default_is_mine_group":1}</field>
<field name="view_id" ref="casmove_tree"/>
<field name="help" type="html">
<p>
Here you can see your cash moves.<br/>A cash moves can be either an expense or a payment.
@ -175,6 +223,7 @@
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_lunch_cashmove_filter"/>
<field name="context">{"search_default_group_by_user":1}</field>
<field name="view_id" ref="casmove_tree_view"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new payment.
@ -196,6 +245,7 @@
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_lunch_employee_payment_filter"/>
<field name="context">{"search_default_is_payment":1}</field>
<field name="view_id" ref="casmove_tree_view"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a payment.
@ -389,39 +439,6 @@
</field>
</record>
<!--view for cashmove-->
<record model="ir.ui.view" id="casmove_tree_view">
<field name="name">cashmove tree</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<tree string="cashmove tree">
<field name="date"/>
<field name="user_id"/>
<field name="description"/>
<field name="amount" sum="Total"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="casmove_form_view">
<field name="name">cashmove form</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<form string="cashmove form" version="7.0">
<sheet>
<group>
<field name="user_id"
context="{'default_groups_ref': ['base.group_user', 'lunch.group_lunch_user']}"/>
<field name="date"/>
<field name="amount"/>
</group>
<label for='description'/>
<field name="description"/>
</sheet>
</form>
</field>
</record>
<!--view for alerts-->
<record model="ir.ui.view" id="alert_tree_view">
<field name="name">alert tree</field>

View File

@ -40,6 +40,11 @@
<field name="args">()</field>
</record>
<!-- Admin should not receivve emails at creation -->
<record id="base.partner_root" model="res.partner">
<field name="notification_email_send">none</field>
</record>
<!-- Discussion subtype for messaging / Chatter -->
<record id="mt_comment" model="mail.message.subtype">
<field name="name">Discussions</field>

View File

@ -658,14 +658,14 @@ class mail_message(osv.Model):
- no model, no res_id, I create a private message OR
- pid in message_follower_ids if model, res_id OR
- mail_notification (parent_id.id, pid) exists, uid has been notified of the parent, OR
- uid have write access on the related document if model, res_id, OR
- uid have write or create access on the related document if model, res_id, OR
- otherwise: raise
- write: if
- author_id == pid, uid is the author, OR
- uid has write access on the related document if model, res_id
- uid has write or create access on the related document if model, res_id
- otherwise: raise
- unlink: if
- uid has write access on the related document if model, res_id
- uid has write or create access on the related document if model, res_id
- otherwise: raise
"""
def _generate_model_record_ids(msg_val, msg_ids=[]):

View File

@ -473,7 +473,8 @@ class mail_thread(osv.AbstractModel):
if not model_obj:
model_obj = self
if operation in ['create', 'write', 'unlink']:
model_obj.check_access_rights(cr, uid, 'write')
if not model_obj.check_access_rights(cr, uid, 'write', raise_exception=False):
model_obj.check_access_rights(cr, uid, 'create')
model_obj.check_access_rule(cr, uid, mids, 'write', context=context)
else:
model_obj.check_access_rights(cr, uid, operation)
@ -814,8 +815,10 @@ class mail_thread(osv.AbstractModel):
# text/plain -> <pre/>
body = tools.append_content_to_html(u'', body, preserve=True)
else:
alternative = (message.get_content_type() == 'multipart/alternative')
alternative = False
for part in message.walk():
if part.get_content_type() == 'multipart/alternative':
alternative = True
if part.get_content_maintype() == 'multipart':
continue # skip container
filename = part.get_filename() # None if normal part

View File

@ -234,7 +234,7 @@ class test_mail(TestMailBase):
# Data creation
# --------------------------------------------------
# 0 - Update existing users-partners
self.res_users.write(cr, uid, [uid], {'email': 'a@a'})
self.res_users.write(cr, uid, [uid], {'email': 'a@a', 'notification_email_send': 'comment'})
self.res_users.write(cr, uid, [self.user_raoul_id], {'email': 'r@r'})
# 1 - Bert Tartopoils, with email, should receive emails for comments and emails
p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'})

View File

@ -81,6 +81,67 @@ Please call me as soon as possible this afternoon!
Sylvie
"""
MAIL_MULTIPART_MIXED = """Return-Path: <ignasse.carambar@gmail.com>
X-Original-To: raoul@grosbedon.fr
Delivered-To: raoul@grosbedon.fr
Received: by mail1.grosbedon.com (Postfix, from userid 10002)
id E8166BFACA; Fri, 23 Aug 2013 13:18:01 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail1.grosbedon.com
X-Spam-Level:
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1
Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173])
by mail1.grosbedon.com (Postfix) with ESMTPS id 9BBD7BFAAA
for <raoul@openerp.fr>; Fri, 23 Aug 2013 13:17:55 +0200 (CEST)
Received: by mail-ie0-f173.google.com with SMTP id qd12so575130ieb.4
for <raoul@grosbedon.fr>; Fri, 23 Aug 2013 04:17:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:date:message-id:subject:from:to:content-type;
bh=dMNHV52EC7GAa7+9a9tqwT9joy9z+1950J/3A6/M/hU=;
b=DGuv0VjegdSrEe36ADC8XZ9Inrb3Iu+3/52Bm+caltddXFH9yewTr0JkCRQaJgMwG9
qXTQgP8qu/VFEbCh6scu5ZgU1hknzlNCYr3LT+Ih7dAZVUEHUJdwjzUU1LFV95G2RaCd
/Lwff6CibuUvrA+0CBO7IRKW0Sn5j0mukYu8dbaKsm6ou6HqS8Nuj85fcXJfHSHp6Y9u
dmE8jBh3fHCHF/nAvU+8aBNSIzl1FGfiBYb2jCoapIuVFitKR4q5cuoodpkH9XqqtOdH
DG+YjEyi8L7uvdOfN16eMr7hfUkQei1yQgvGu9/5kXoHg9+Gx6VsZIycn4zoaXTV3Nhn
nu4g==
MIME-Version: 1.0
X-Received: by 10.50.124.65 with SMTP id mg1mr1144467igb.43.1377256674216;
Fri, 23 Aug 2013 04:17:54 -0700 (PDT)
Received: by 10.43.99.71 with HTTP; Fri, 23 Aug 2013 04:17:54 -0700 (PDT)
Date: Fri, 23 Aug 2013 13:17:54 +0200
Message-ID: <CAP76m_V4BY2F7DWHzwfjteyhW8L2LJswVshtmtVym+LUJ=rASQ@mail.gmail.com>
Subject: Test mail multipart/mixed
From: =?ISO-8859-1?Q?Raoul Grosbedon=E9e?= <ignasse.carambar@gmail.com>
To: Followers of ASUSTeK-Joseph-Walters <raoul@grosbedon.fr>
Content-Type: multipart/mixed; boundary=089e01536c4ed4d17204e49b8e96
--089e01536c4ed4d17204e49b8e96
Content-Type: multipart/alternative; boundary=089e01536c4ed4d16d04e49b8e94
--089e01536c4ed4d16d04e49b8e94
Content-Type: text/plain; charset=ISO-8859-1
Should create a multipart/mixed: from gmail, *bold*, with attachment.
--
Marcel Boitempoils.
--089e01536c4ed4d16d04e49b8e94
Content-Type: text/html; charset=ISO-8859-1
<div dir="ltr">Should create a multipart/mixed: from gmail, <b>bold</b>, with attachment.<br clear="all"><div><br></div>-- <br>Marcel Boitempoils.</div>
--089e01536c4ed4d16d04e49b8e94--
--089e01536c4ed4d17204e49b8e96
Content-Type: text/plain; charset=US-ASCII; name="test.txt"
Content-Disposition: attachment; filename="test.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hkpb27k00
dGVzdAo=
--089e01536c4ed4d17204e49b8e96--"""
class TestMailgateway(TestMailBase):
@ -220,6 +281,24 @@ class TestMailgateway(TestMailBase):
self.assertEqual(mail.reply_to, msg.email_from,
'mail_mail: incorrect reply_to: should be message email_from')
def test_09_message_parse(self):
""" Testing incoming emails parsing """
cr, uid = self.cr, self.uid
res = self.mail_thread.message_parse(cr, uid, MAIL_TEMPLATE_PLAINTEXT)
self.assertIn('Please call me as soon as possible this afternoon!', res.get('body', ''),
'message_parse: missing text in text/plain body after parsing')
res = self.mail_thread.message_parse(cr, uid, MAIL_TEMPLATE)
self.assertIn('<p>Please call me as soon as possible this afternoon!</p>', res.get('body', ''),
'message_parse: missing html in multipart/alternative body after parsing')
res = self.mail_thread.message_parse(cr, uid, MAIL_MULTIPART_MIXED)
self.assertNotIn('Should create a multipart/mixed: from gmail, *bold*, with attachment', res.get('body', ''),
'message_parse: text version should not be in body after parsing multipart/mixed')
self.assertIn('<div dir="ltr">Should create a multipart/mixed: from gmail, <b>bold</b>, with attachment.<br clear="all"><div><br></div>', res.get('body', ''),
'message_parse: html version should be in body after parsing multipart/mixed')
def test_10_message_process(self):
""" Testing incoming emails processing. """
cr, uid, user_raoul = self.cr, self.uid, self.user_raoul
@ -459,7 +538,7 @@ class TestMailgateway(TestMailBase):
frog_group = self.mail_group.browse(cr, uid, frog_groups[0])
msg = frog_group.message_ids[0]
# Test: plain text content should be wrapped and stored as html
self.assertEqual(msg.body, '<pre>\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n</pre>',
self.assertIn('<pre>\nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n</pre>', msg.body,
'message_process: plaintext incoming email incorrectly parsed')
def test_20_thread_parent_resolution(self):

View File

@ -189,7 +189,7 @@
<field name="time_stop" widget="float_time"/>
</group>
<group string="Costing Information">
<field name="product_id" on_change="on_change_product_cost(product_id)"/>
<field name="product_id" on_change="on_change_product_cost(product_id)" context="{'default_supply_method':'produce'}"/>
<field name="costs_hour"/>
<field name="costs_hour_account_id" groups="analytic.group_analytic_accounting"/>
<field name="costs_cycle"/>
@ -248,7 +248,7 @@
<field name="model">mrp.routing.workcenter</field>
<field name="arch" type="xml">
<form string="Routing Work Centers" version="7.0">
<group col="4" string="General Information">
<group col="4">
<field colspan="4" name="name"/>
<field name="sequence"/>
<field name="workcenter_id"/>
@ -280,7 +280,7 @@
</group>
<notebook>
<page string="Work Center Operations">
<field name="workcenter_lines"/>
<field name="workcenter_lines" string="Operation"/>
</page>
<page string="Notes">
<field name="note"/>
@ -422,6 +422,7 @@
<field name="arch" type="xml">
<search string="Search Bill Of Material">
<field name="name" string="Bill Of Material" filter_domain="['|',('name','ilike',self),('code','ilike',self)]"/>
<field name="bom_lines" string="Components"/>
<field name="product_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<group expand="0" string="Group By...">
@ -513,7 +514,18 @@
</p>
</field>
</record>
<record id="product_search_form_view_procurment" model="ir.ui.view">
<field name="name">product.search.bom</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_search_form_view"/>
<field name="arch" type="xml">
<xpath expr="//filter[@string='Consumable']" position="after">
<separator/>
<filter string="Components" name="components" icon="terp-accessories-archiver" domain="[('bom_ids','not in',[]),('bom_ids.bom_id','!=',False)]" invisible="not context.get('search_default_filter_supply_method_produce', False)"/>
</xpath>
</field>
</record>
<record id="product_supply_method_produce" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">product.product</field>
@ -537,15 +549,15 @@
action="mrp_bom_form_action2"
id="menu_mrp_bom_form_action2"
parent="menu_mrp_configuration"
groups="base.group_no_one"
sequence="20"/>
<record id="action2" model="ir.actions.act_window">
<field name="name">Bill of Materials Structure</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.bom</field>
<field name="domain">[('bom_id', '=',active_ids)]</field>
<field name="domain">[('id', 'in', active_ids)]</field>
<field name="view_id" ref="mrp_bom_tree_view"/>
<field name="view_type">tree</field>
</record>
<record id="ir_BOM_structure" model="ir.values">
<field eval="'client_action_multi'" name="key2"/>
@ -693,7 +705,7 @@
</field>
</group>
<group string="Consumed Products">
<field name="move_lines2" nolabel="1">
<field name="move_lines2" nolabel="1" options="{'reload_on_button': true}">
<tree colors="red:scrapped==True;blue:state == 'draft';black:state in('picking_except','confirmed','ready','in_production');gray:state == 'cancel' " string="Consumed Products" editable="bottom">
<field name="product_id" readonly="1"/>
<field name="product_qty" readonly="1"/>
@ -709,7 +721,7 @@
<page string="Finished Products">
<group>
<group string="Products to Produce">
<field name="move_created_ids" nolabel="1">
<field name="move_created_ids" nolabel="1" options="{'reload_on_button': true}">
<tree string="Products to Finish">
<field name="product_id"/>
<field name="product_qty"/>
@ -723,7 +735,7 @@
</field>
</group>
<group string="Produced Products">
<field name="move_created_ids2" nolabel="1">
<field name="move_created_ids2" nolabel="1" options="{'reload_on_button': true}">
<tree colors="red:scrapped==True;blue:state == 'draft';black:state in('picking_except','confirmed','ready','in_production');gray:state in('cancel','done') " string="Finished Products">
<field name="product_id" readonly="1"/>
<field name="product_qty" readonly="1"/>
@ -974,7 +986,7 @@
<!-- Menu for Resource for MRP-->
<record id="mrp_workcenter_action" model="ir.actions.act_window">
<field name="name">Work Center</field>
<field name="name">Work Centers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.workcenter</field>
<field name="view_type">form</field>
@ -1016,6 +1028,7 @@
<field name="name">Bill of Materials</field>
<field name="domain">[('bom_id','=',False)]</field>
<field name="res_model">mrp.bom</field>
<field name="view_type">tree</field>
</record>
<record id="act_product_mrp_production" model="ir.actions.act_window">
<field name="context">{'search_default_product_id': [active_id]}</field>

View File

@ -36,7 +36,7 @@ class mrp_config_settings(osv.osv_memory):
* Repair quotation report
* Notes for the technician and for the final customer.
This installs the module mrp_repair."""),
'module_mrp_operations': fields.boolean("Allow detailed planning of work order",
'module_mrp_operations': fields.boolean("Allow detailed planning of work orders",
help="""This allows to add state, date_start,date_stop in production order operation lines (in the "Work Centers" tab).
This installs the module mrp_operations."""),
'module_mrp_byproduct': fields.boolean("Produce several products from one manufacturing order",
@ -60,7 +60,7 @@ class mrp_config_settings(osv.osv_memory):
help="""Routings allow you to create and manage the manufacturing operations that should be followed
within your work centers in order to produce a product. They are attached to bills of materials
that will define the required raw materials."""),
'group_mrp_properties': fields.boolean("Allow several bill of materials per products using properties",
'group_mrp_properties': fields.boolean("Allow several bill of materials per product using properties",
implied_group='product.group_mrp_properties',
help="""The selection of the right Bill of Material to use will depend on the properties specified on the sales order and the Bill of Material."""),
'module_product_manufacturer': fields.boolean("Define manufacturers on products ",

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import test_multicompany
checks = [
test_multicompany,
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tests import common
class TestMrpMulticompany(common.TransactionCase):
def setUp(self):
super(TestMrpMulticompany, self).setUp()
cr, uid = self.cr, self.uid
# Usefull models
self.ir_model_data = self.registry('ir.model.data')
self.res_users = self.registry('res.users')
self.stock_location = self.registry('stock.location')
model, self.multicompany_user_id = self.ir_model_data.get_object_reference(cr, uid, 'stock', 'multicompany_user')
def test_00_multicompany_user(self):
"""check no error on getting default mrp.production values in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['location_src_id', 'location_dest_id']
defaults = self.stock_location.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
for field in fields:
print field, uid, defaults
if defaults.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)

View File

@ -31,7 +31,7 @@
<button name="repair_ready" states="confirmed,ready" string="Start Repair" class="oe_highlight"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name="action_repair_end" states="under_repair" string="End Repair" class="oe_highlight"/>
<button name="action_invoice_create" states="2binvoiced" string="Make Invoice" class="oe_highlight"/>
<button name="action_invoice_create" states="2binvoiced" string="Create Invoice" class="oe_highlight"/>
<button name="invoice_recreate" states="invoice_except" string="Recreate Invoice"/>
<button name="invoice_corrected" states="invoice_except" string="Invoice Corrected"/>
<button name="action_cancel" string="Cancel Repair" type="object" attrs="{'invisible':['|',('invoice_method','!=','none'), ('state', 'not in',('confirmed','2binvoiced','ready','under_repair', 'invoice_except'))]}"/>

View File

@ -21,7 +21,7 @@
</field>
</record>
<act_window name="Make Invoice"
<act_window name="Create Invoice"
res_model="mrp.repair.make_invoice"
src_model="mrp.repair"
view_mode="form"

View File

@ -940,11 +940,12 @@ class pos_order(osv.osv):
user_company = user_proxy.browse(cr, order.user_id.id, order.user_id.id).company_id
group_tax = {}
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context).id
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
order_account = order.partner_id and \
order.partner_id.property_account_receivable and \
order.partner_id.property_account_receivable.id or account_def or current_company.account_receivable.id
order.partner_id.property_account_receivable.id or \
account_def and account_def.id or current_company.account_receivable.id
if move_id is None:
# Create an entry for the sale

View File

@ -8,6 +8,7 @@
<field name="email">demo@portal.example.com</field>
<field name="supplier" eval="False"/>
<field name="customer" eval="True"/>
<field name="notification_email_send">none</field>
</record>
<record id="demo_user0" model="res.users">
<field name="partner_id" ref="partner_demo_portal"/>

View File

@ -9,7 +9,7 @@
<field name="arch" type="xml">
<group name="procurement" position="inside">
<group string="Manufacturer">
<field name="manufacturer" />
<field name="manufacturer" context="{'default_supplier':True, 'default_customer':False}"/>
<field name="manufacturer_pname"/>
<field name="manufacturer_pref"/>
</group>

View File

@ -79,6 +79,13 @@ class project(osv.osv):
"mail.alias": "alias_id"}
_inherit = ['mail.thread', 'ir.needaction_mixin']
def _auto_init(self, cr, context=None):
""" Installation hook: aliases, project.project """
# create aliases for all projects and avoid constraint errors
alias_context = dict(context, alias_model_name='project.task')
self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(project, self)._auto_init,
self._columns['alias_id'], 'id', alias_prefix='project+', alias_defaults={'project_id':'id'}, context=alias_context)
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
if user == 1:
return super(project, self).search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)

View File

@ -36,6 +36,7 @@
<record id="group_mrp_properties" model="res.groups">
<field name="name">Properties on lines</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
<field name="category_id" ref="base.module_category_hidden"/>
</record>

View File

@ -302,6 +302,7 @@ class sale_order(osv.osv):
'move_id': move_id,
'company_id': order.company_id.id,
'note': line.name,
'property_ids': [(6, 0, [x.id for x in line.property_ids])],
}
def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None):

View File

@ -21,20 +21,23 @@
import time
from openerp.report import report_sxw
from openerp.osv import osv
class picking(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(picking, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'get_product_desc':self.get_product_desc
'get_product_desc': self.get_product_desc,
})
def get_product_desc(self,move_line):
def get_product_desc(self, move_line):
desc = move_line.product_id.name
if move_line.product_id.default_code:
desc = '[' + move_line.product_id.default_code + ']' + ' ' + desc
return desc
report_sxw.report_sxw('report.stock.picking.list','stock.picking','addons/stock/report/picking.rml',parser=picking)
for suffix in ['', '.in', '.out']:
report_sxw.report_sxw('report.stock.picking.list' + suffix,
'stock.picking' + suffix,
'addons/stock/report/picking.rml',
parser=picking)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2930,12 +2930,22 @@ class stock_warehouse(osv.osv):
}
def _default_lot_input_stock_id(self, cr, uid, context=None):
lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
return lot_input_stock.id
try:
lot_input_stock_model, lot_input_stock_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
self.pool.get('stock.location').check_access_rule(cr, uid, [lot_input_stock_id], 'read', context=context)
except (ValueError, orm.except_orm):
# the user does not have read access on the location or it does not exists
lot_input_stock_id = False
return lot_input_stock_id
def _default_lot_output_id(self, cr, uid, context=None):
lot_output = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_output')
return lot_output.id
try:
lot_input_stock_model, lot_input_stock_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_output')
self.pool.get('stock.location').check_access_rule(cr, uid, [lot_input_stock_id], 'read', context=context)
except (ValueError, orm.except_orm):
# the user does not have read access on the location or it does not exists
lot_output_id = False
return lot_output_id
_defaults = {
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),

View File

@ -287,6 +287,16 @@
<field name="company_id" ref="base.main_company"/>
</record>
<record id="multicompany_user" model="res.users">
<field name="name">multicomp</field>
<field name="login">multicomp</field>
<field name="password">multicomp</field>
<field name="company_id" ref="res_company_2"/>
<field name="company_ids" eval="[(6,0,[ref('res_company_2')])]"/>
<field name="groups_id" eval="[(6,0,[ref('base.group_user'), ref('stock.group_stock_manager')])]"/>
</record>
</data>
</openerp>

View File

@ -3,8 +3,8 @@
<data>
<report auto="False" id="report_product_history" model="product.product" name="stock.product.history" string="Stock Level Forecast"/>
<report id="report_picking_list" model="stock.picking" name="stock.picking.list" string="Picking Slip" rml="stock/report/picking.rml"/>
<report id="report_picking_list_in" model="stock.picking.in" name="stock.picking.list" string="Receipt Slip" rml="stock/report/picking.rml"/>
<report id="report_picking_list_out" model="stock.picking.out" name="stock.picking.list" string="Delivery Slip" rml="stock/report/picking.rml"/>
<report id="report_picking_list_in" model="stock.picking.in" name="stock.picking.list.in" string="Receipt Slip" rml="stock/report/picking.rml"/>
<report id="report_picking_list_out" model="stock.picking.out" name="stock.picking.list.out" string="Delivery Slip" rml="stock/report/picking.rml"/>
<report id="report_move_labels" model="stock.move" name="stock.move.label" string="Item Labels" xml="stock/report/lot_move_label.xml" xsl="stock/report/lot_move_label.xsl"/>
<report auto="False" id="report_location_overview" model="stock.location" name="lot.stock.overview" string="Location Inventory Overview" rml="stock/report/lot_overview.rml"/>
<report id="report_location_overview_all" model="stock.location" name="lot.stock.overview_all" string="Location Content" rml="stock/report/lot_overview_all.rml"/>

View File

@ -161,7 +161,7 @@
</field>
</page>
<page string="Posted Inventory">
<field name="move_ids" context="{'inventory_id':active_id}" >
<field name="move_ids" context="{'inventory_id':active_id}" options='{"reload_on_button": true}' >
<tree string="Stock Moves">
<field name="product_id"/>
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
@ -786,7 +786,7 @@
</group>
<notebook>
<page string="Products">
<field name="move_lines" context="{'address_in_id': partner_id, 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree', 'picking_type': 'internal'}"/>
<field name="move_lines" context="{'address_in_id': partner_id, 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree', 'picking_type': 'internal'}" options='{"reload_on_button": true}'/>
<field name="note" placeholder="Add an internal note..." class="oe_inline"/>
</page>
<page string="Additional Info">
@ -921,7 +921,7 @@
<field name="partner_id" on_change="onchange_partner_in(partner_id)" string="Customer" domain="[('customer','=',True)]" />
</xpath>
<xpath expr="//field[@name='move_lines']" position="replace">
<field name="move_lines" context="{'address_out_id': partner_id, 'picking_type': 'out', 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}"/>
<field name="move_lines" context="{'address_out_id': partner_id, 'picking_type': 'out', 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}" options='{"reload_on_button": true}'/>
</xpath>
<xpath expr="/form/sheet" position="after">
<div class="oe_chatter">
@ -1048,7 +1048,7 @@
<field name="partner_id" on_change="onchange_partner_in(partner_id)" string="Supplier" domain="[('supplier','=',True)]" />
</xpath>
<xpath expr="//field[@name='move_lines']" position="replace">
<field name="move_lines" context="{'address_in_id': partner_id, 'picking_type': 'in', 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}"/>
<field name="move_lines" context="{'address_in_id': partner_id, 'picking_type': 'in', 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree'}" options='{"reload_on_button": true}'/>
</xpath>
<xpath expr="/form/sheet" position="after">
<div class="oe_chatter">

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import test_multicompany
checks = [
test_multicompany,
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tests import common
class TestStockMulticompany(common.TransactionCase):
def setUp(self):
super(TestStockMulticompany, self).setUp()
cr, uid = self.cr, self.uid
# Usefull models
self.ir_model_data = self.registry('ir.model.data')
self.res_users = self.registry('res.users')
self.stock_location = self.registry('stock.location')
self.stock_move = self.registry('stock.move')
self.stock_fill_inventory = self.registry('stock.fill.inventory')
self.stock_warehouse = self.registry('stock.warehouse')
model, self.multicompany_user_id = self.ir_model_data.get_object_reference(cr, uid, 'stock', 'multicompany_user')
def test_00_multicompany_default_stock_move(self):
"""check no error on getting default stock.move values in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['location_id', 'location_dest_id']
for type in ('in', 'internal', 'out'):
context['picking_type'] = type
defaults = self.stock_move.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
for field in fields:
if defaults.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
self.assertEqual(defaults['type'], type, "wrong move type")
def test_10_multicompany_onchange_move_type(self):
"""check onchange_move_type does not return unreadable in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['location_id', 'location_dest_id']
for type in ('in', 'internal', 'out'):
result = self.stock_move.onchange_move_type(cr, uid, [], type, context)['value']
for field in fields:
if result.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [result[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
def test_20_multicompany_default_stock_fill_inventory(self):
"""check default location readability for stock_fill_inventory in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
defaults = self.stock_fill_inventory.default_get(cr, uid, ['location_id'], context)
if defaults.get('location_id'):
try:
self.stock_location.check_access_rule(cr, uid, [defaults['location_id']], 'read', context)
except Exception, exc:
assert False, "unreadable source location: %s" % exc
def test_30_multicompany_default_warehouse_location(self):
"""check default locations for warehouse in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['lot_input_id', 'lot_stock_id', 'lot_output_id']
defaults = self.stock_warehouse.default_get(cr, uid, fields, context)
for field in fields:
if defaults.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable default %s: %s" % (field, exc)

View File

@ -19,7 +19,7 @@
#
##############################################################################
from openerp.osv import fields, osv
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
class stock_fill_inventory(osv.osv_memory):
@ -28,8 +28,10 @@ class stock_fill_inventory(osv.osv_memory):
def _default_location(self, cr, uid, ids, context=None):
try:
loc_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
except ValueError, e:
location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
location.check_access_rule('read', context=context)
location_id = location.id
except (ValueError, orm.except_orm), e:
return False
return location_id or False