콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

I need to configure the sequence number for my sales quotation. And also I have three companies. I want 

Company1 - AAN01

Company2 - ABM01

Company3 - AZX01

What is the python code for the above requirement?

   @api.model
    def create(self,vals):
            if vals.get('sequence_name', _('New')) == _('New'):
                vals['sequence_name'] = self.env['ir.sequence'].next_by_code('sale.order') or _('New')
            res = super(sale_order, self).create(vals)
            return res


<record id="seq_sale_order" model="ir.sequence">
<field name="name">Sales Order</field>
<field name="code">sale.orders</field>
<field name="prefix">AAN</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>



아바타
취소
베스트 답변

Hi Remya,

You can just go to: Settings / Technical / Sequences & Identifiers / Sequences / sale.order , and you can create separate sequences for each company (duplicate existing sequence and create one for each company).

See also the answer from:  https://www.odoo.com/forum/help-1/question/configuration-on-odoo-v-13-multi-company-setup-158830#answer-158840

BR

Ricardo




아바타
취소
작성자

That's ok. But I need to implement it through my customized code. Plz guide me to correct the below code

베스트 답변

Hi bro,

To do that you need first to create 3 sequences and define their names and prefix.

Then add this code in your class : 

@api.model
def create(self,vals):
	if self.company_id and vals.get('name', '/') == '/':
		if self.company_id.name =="YourFirstCompanyName":#Company1 
			seq_id = self.pool.get('ir.model.data').get_object_reference(self._cr,self._uid,'sale_order', 'YourCompany1SequenceID')[1]
			self.name = self.pool.get('ir.sequence').get_id(self._cr,self._uid , seq_id, 'id',self._context)

if self.company_id.name =="YourSecondCompanyName":#Company2 seq_id = self.pool.get('ir.model.data').get_object_reference(self._cr,self._uid,'sale_order', 'YourCompany2SequenceID')[1] self.name = self.pool.get('ir.sequence').get_id(self._cr,self._uid , seq_id, 'id',self._context)
if self.company_id.name =="YourThirdCompanyName":#Company3 seq_id = self.pool.get('ir.model.data').get_object_reference(self._cr,self._uid,'sale_order', 'YourCompany3SequenceID')[1] self.name = self.pool.get('ir.sequence').get_id(self._cr,self._uid , seq_id, 'id',self._context) return super(sale_order, self).create(vals)
YourCompany3SequenceID = xml ID of the  sequence for the third company. 

Dont forget to vote positif :)


아바타
취소
작성자

Very thankful for your answer. YourCompany3SequenceID = seq_sale_order

{. <record id="seq_sale_order" model="ir.sequence">}. Right???

작성자

Yet I didn't get any solution

brther you have tocreate 2 more other sequences , the standard one is what you mentionned, you can use it as sequence for the first company , but you need to create 2 more sequences one for the second company and one for the third.

and it's a tested solution :) it works i promise

작성자

Hi, I had created 3 sequences for my three different company and mentioned as the above code. But it is not creating a sequence code.

But I will try to solve the issue in my code. Thanks for your reply

관련 게시물 답글 화면 활동
2
7월 25
1913
3
7월 25
2328
1
7월 25
1590
0
4월 25
2619
3
11월 24
361