Hi guys
The default behaviour from A -> Z for creating quotations is perfect and I want a second method for 'Internal' quotations which does 99% the same. By default there is no customer filled in when you create a new quotation under sales. I now want a second menu item 'Internal quotations' which does the same as quotations but by default the customer 'Internal customer' should be filled in.
I've made a custom module 'aa_maatwerk' which makes the new menu item through XML:
<menuitem id="menu_item_offertes" name="Internal quotations" parent="base.menu_sales"
action="sale.action_quotations_intern" sequence="5"/>
As you can see this action links to sale.action_quotations_intern which is in the file sale_view.xml in the module sale. I've basicly copied the record action_quotations and then created a new one with the name action_quotations_intern like this:
<record id="action_quotations_intern" model="ir.actions.act_window">
<field name="name">Offertes - Intern</field>
<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="view_quotation_tree"/>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="context">{'search_default_my_sale_orders_filter': 0,'type':'internal'}</field>
<field name="domain">[('partner_id.name','=','Intern'),('state','in',('draft','sent','cancel'))]</field>
<field name="search_view_id" ref="view_sales_order_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a quotation, the first step of a new sale.
</p><p>
Odoo will help you handle efficiently the complete sale flow:
from the quotation to the sales order, the
delivery, the invoicing and the payment collection.
</p><p>
The social feature helps you organize discussions on each sales
order, and allow your customers to keep track of the evolution
of the sales order.
</p>
</field>
</record>
I now have two problems:
1) I would like to have everything in my custom module, to keep it seperated
2) When the user clicks on the menu item 'Internal quotations' the customer dropdown should be filled in by default with the customer 'Internal customer'.
Could anybody tell me how I can get all of this in one module, how to inherit this correctly and then fill in the customer name?
I have also inherited the sale class in sale_order.py in my custom module (aa_maatwerk) like this:
# -*- coding: utf-8 -*-
from openerp import http
from openerp imports models, fields,apiclass SaleOrder(http.Controller):
_inherit = 'sale.order'
type = fields.Selection(selection=type_sel, string='Type')#I assume that this should override the 'old' class/method somehow?
def create(self, cr, uid, values, context=None):
type = context.get('type',False) # check for type in context
if type == 'internal':
values['partner_id'] = self.pool.get('res.partner').search(cr, uid, 'Internal customer')[0] # assuming find WILL return one ID!
values['type'] = 'internal' # create with type internal...
return super(sale_order, self).create(cr, uid, values, context=None)
And I've also added the data and dependencies in my __openerp__py file:
# any module necessary for this one to work correctly
'depends': ['base','sale','procurement','purchase'],# always loaded
'data': [
# 'security/ir.model.access.csv',
'templates.xml',
],
But this doesn't seem to do anything and my customer is not filled in by default either.
With kind regards
Yenthe
Still no solution on this so I'll kindly 'bump' this.