Each Partner Community user associated with the same account gets a unique Role. When a Partner Community user registers from say, Acme Widgets, that user gets the role Acme Widgets User or something of the sort. Every other user who registers related to the Acme Widgets account also gets that role. Users related to other accounts get their own unique role based on that account name.
Partner Communities have access to the full sharing model, while Customer Communities can only access Sharing Sets and Sharing Groups.
Since each partner user has an account-specific role, it's going to become really tedious to create sharing rules for each partner account. You certain could do what you're asking this way, object by object, one rule for each account. That's a lot of sharing rules. The other option, and it's what I would recommend here, is to create rules using apex manual sharing and a trigger on your object(s) to automatically share it with other users having the same role as the record owner, one trigger for each object. Documentation on apex sharing here:
Sharing a Record Using Apex
The process is very much similar to how you set up for Internal Users except that you need to replace with Community URLS .
Lets look at step by step the mechanism to accomplish the same .For simplicity I am taking another winter 17 pre release org as a SP (Service Provider)
Step 1
Set Up a Partner Community in Salesforce(This is your IDP org) .Not going to detail this but should be straight forward
Step 2
Download the Self Signed Certificate from your IDP org .Your IDP org is where you have set up partner community .Navigate to
Setup | Security Controls | Identity Provider
Click on Download Certificate button
You will clearly see for your Partner Community there will be Discovery EndPoint URL .Carefully Note this down as this will be needed by your Service Provider .Also note down the issuer
Step 3
Lets go to the service provider screen .In my example its another salesforce Instance (Winter 17 pre release org ).
Set up | Security Control | Single Sign On Settings
Carefully note two things
1.The issuer was obtained from IDP .
2.The IDP login URL is of one we noted in step 2 from IDP
3.We have uploaded the certificate which we downloaded in previous step
Step 4
Create a Connected App in IDP and allow the partner community profile for the connected app
Carefully note that I have configured ACS URL which was provided by the service provider in previous step
Once your connected app is save and when you click on Detail link of the the Connected App ,for every community you will get an IDP intitated URL
The IDP initiated login URL is what you need to put on a tab or visualforce .You will then see that User is redirected to the SP once user clicks on the IDP initiated URL without having to log into the SP org .
Best Answer
First, quick clarification, there is no such thing as a partner community or customer community any more as it was with portals. Salesforce communities can have members that are internal users, Chatter Free users, customer community users, partner community users, etc. all under one roof.
My best advice for document sharing within a community is to consider using Chatter and Chatter Files. Most of Salesforce.com innovation and energy over the past few releases has focused on making Chatter and the feed a primary place to share files and documents. The Files tab can be surfaced to a community in the Manage Communities config interface.